Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!xanth!ames!pioneer.arc.nasa.gov!pcsuprt From: pcsuprt@pioneer.arc.nasa.gov (pcsuprt group) Newsgroups: comp.lang.pascal Subject: Re: Question about Turbo Pascal's Exec Keywords: Turbo Pascal v4.0 exec Message-ID: <25135@ames.arc.nasa.gov> Date: 8 May 89 21:59:01 GMT References: <5708@cs.Buffalo.EDU> Sender: usenet@ames.arc.nasa.gov Reply-To: pcsuprt@pioneer.arc.nasa.gov.UUCP (pcsuprt group) Distribution: usa Organization: NASA-Ames Research Center Lines: 30 In reference to Exec(path, cmdline : string). Path - this is the full path, name and extension of the program that you want to execute. Cmdline - this line will be passed to the executed program as a parm. Thus to execute ted on autoexec.bat you would use: Exec('c:\ted.com','c:\autoexec.bat'); (This assumes that ted.com is in the root on c:). If ted is in the path and you don't wan't to specify exactly where it is then use: Exec('c:\command.com',' /c ted c:\autoexec.bat'); This loads the command interpreter and tells it to find ted and run it (takes more memory and is slower). When using the EXEC command be sure to pay attention to the memory. Since the pascal program remains resident, you have that much less memory to play with. In particular, I have had to set the stacksize to the maximum ( 65520 bytes ) in order to use exec in a program I wrote. I used the compiler directive {$M 65520,0,65536}. Also, when testing the program compile it to disk instead of memory to make more RAM available to Exec. The DosError variable should be checked after running exec. DosError will tell you if you ran out of memory (8) or if the file could not be found (2), etc. DosExitCode is supposed to be the returncode from the program that exec ran (although I haven't ever used it). Dave Silvestro, Sterling Software, NASA/Ames Research Center Moffett Field, CA pcsuprt@pioneer.arc.nasa.gov