Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!vsi1!octopus!stever From: stever@Octopus.COM (Steve Resnick ) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: listing of errorlevel codes wanted Message-ID: <1990Jun13.173331.15186@Octopus.COM> Date: 13 Jun 90 17:33:31 GMT References: <1990Jun11.234451.6632@xrtll.uucp> <1990Jun13.031828.17936@athena.mit.edu> Reply-To: stever@octopus.UUCP (Steve Resnick ) Organization: Octopus Enterprises, Cupertino CA Lines: 62 In article <1990Jun13.031828.17936@athena.mit.edu> lfk@E40-008-6.mit.edu (Lee F Kolakowski) writes: > >On 11 Jun 90 23:44:51 GMT, >silver@xrtll.uucp (Hi Ho Silver) said: >> In article sarra@zeppelin.rutgers.edu (William) writes: >> $Does anyone out there have a listing of the errorlevel codes and their >> $respective meanings? If so, would you please send it to me, I have a >> $need for it's use in an assembly language program. > >> There are no assigned meanings to errorlevel codes. It's up to the >> designer of each program to determine what results should be returned >> using the return value you read with errorlevel, and to assign numbers to >> these. > >Sure there are standards (loose ones anyway!), and they come from >where all the good DOS programming ideas come from (Unix). > > Return Code Meaning > 0 No Errors > 1 Something went wrong (often in parameters or data) > 2-infinity Something else went wrong > >These codes are used as valuse to exit() or return in C programs for >example. > >For commands that test expressions like 1 == x usually return 0 if >assertion is false, 1 if assertion in true, and 2 if there is a syntax >error or something else. Documentation for the program should define >what the exit codes are. Better error messages also relieve one from >worrying about what these codes mean. > > This is true under DOS but it gets interesting under OS/2's CMD.EXE and maybe this will be true under a newer DOS as well (who knows what IBM will do next..) Under OS/2 you can do multiple commands and conditional commandline processing which throws this scheme off a little: Commands which terminate with an ERRORLEVEL != 0 are considered SUCCESSFULL and commands which terminate with an ERRORLEVEL 0 are failed (I believe this is true under UNIX as well.. ) This is more or less conventional to C and as we all know the DOS batch/command line evaluation is similar to C. For example: This command will run foo and bar if foo is successfull: C:\] FOO && BAR This will only run BAR if FOO fails: C:\] FOO || BAR If FOO's developer wrote FOO so that it returned an errorlevel 0 then the logic would be reversed. More mindless chatter..... :) Steve -- -------------------------------------------------------------------------------- Steve Resnick - 408/241-1533 Process Scientific, Inc. --------------------------------------------------------------------------------