Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!oddjob!gargoyle!ihnp4!cuae2!killer!toma From: toma@killer.UUCP (Tom Armistead) Newsgroups: comp.lang.c Subject: Re: 1 Turbo C question (used to be 2) Message-ID: <1445@killer.UUCP> Date: Sun, 30-Aug-87 19:35:43 EDT Article-I.D.: killer.1445 Posted: Sun Aug 30 19:35:43 1987 Date-Received: Fri, 4-Sep-87 05:35:28 EDT References: <9061@brl-adm.ARPA> Organization: The Org. for the Disorg. of Org. Lines: 39 Summary: use the DOS errorlevel batch variable In article <9061@brl-adm.ARPA>, bonak%cs.uiowa.edu@RELAY.CS.NET (Esmail Bonakdarian) writes: > > Does anybody know a way of getting MS-DOS to use the return > value of an exit(value) that comes from a C program > termination? I.e. I'd like to know (at a DOS level) whether > a program terminated with exit(0) or exit(1). You have something in dos called errorlevel that will give you the value you exit()ed with. This could be used in a batch file like this... . REM RUN MAIN PROGRAM . MAINPGM . IF ERRORLEVEL 0 GOTO GOOD . IF ERRORLEVEL 1 GOTO BAD . IF ERRORLEVEL 2 GOTO HAWAII . :GOOD . ECHO WE GOT A GOOD RETURN . GOTO END . :BAD . ECHO WE GOT A BAD RETURN . GOTO END . :HAWAII . ECHO WE ARE GOING TO HAWII . :END . EXIT the number following 'ERRORLEVEL' will be the number you exited with. Hope this will help... toma UUCP: ihnp4\ \killer!toma infoswx!convex!dj3b1/ Tom Armistead -- UUCP: ihnp4\ \killer!toma infoswx!convex!dj3b1/ Tom Armistead