Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!suvax1!hirayama From: hirayama@suvax1.UUCP (Pat Hirayama) Newsgroups: comp.lang.pascal Subject: Re: TurboP ErrorLevel return question Message-ID: <869@suvax1.UUCP> Date: 3 Jan 88 08:14:52 GMT References: <11028@brl-adm.ARPA> Organization: Seattle University, Seattle, WA. Lines: 65 in article <11028@brl-adm.ARPA>, kirsch@braggvax.arpa (David Kirschbaum) says: > > Richard asks how to return an ERRORLEVEL value from Turbo Pascal 3.0. > Haven't actually tested this, but the manual (p135) on the Procedure Halt says: > > "In PC/MSDOS, Halt may optionally pass a (sic) integer parameter specifying > the return code of the program. Halt without a parameter corresponds > to Halt(0). The return code may be examined by the parent process us- > ing an MS-DOS system function call or through an ERRORLEVEL test > in an MS-DOS batch file." In TP4.0, the manual (p. 430) states the following about Halt: Function Stops program execution and returns to the operating system. Declaration Halt [ ( exitcode: word ) ] Remarks *exitcode* is an optional expression of type word that specifies the exit code of the program. *Halt* without a parameter corresponds to Halt(0). The exit code can be examined by a parent process using the DosExitCode function in the Dos unit or through an ERRORLEVEL test in a DOS batch file. Note that *Halt* will initiate execution of any unit *Exit* procedures. Also in TP4.0 manual (p.393): DosExitCode function Function Returns the exit code of a subprocess. Declaration DosExitCode Result Type word Remarks The low byte is the code sent by the terminating process. The high byte is 0 for normal termination, 1 if terminated by Ctrl-C, 2 if terminated due to a device error, or 3 if terminated by the Keep procedure. Also in TP4.0 manual (p.438): Keep procedure Function Keep (or Terminate Stay Resident) terminates the program and makes it stay in memory. Declaration Keep(ExitCode: word) Remarks The entire program stays in memory--including data segment, stack segment, and heap--so be sure to specify a maximum size for the heap using the $M compiler directive. The *ExitCode* corresponds to the one passed to the *Halt* standard procedure. Restrictions Use with care! Terminate Stay Resident (TSR) programs are complex and *no* other support for them is provided. Refer to the MS-DOS technical documentation for more information. I hope that some of this helps. ------------------------------------------------------------------------------ - Pat Hirayama - Seattle University E-Mail: ...!dataio!suvax1!hirayama USNail: 28625-47th Place South, Auburn, WA 98001-1140 As soon as a still-to-be finished computer task becomes a life-or-death situation, the power fails. ------------------------------------------------------------------------------