" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#008000" VLINK="004000" ALINK="#00C000">
ERRORLEVEL [<rel>] <number>
In PTS-DOS environment any external (for the Shell) command has a
so-called exit code - a number from 0 to 255. This code enables external
components of the executed program to detect errors made during the program
run and return error messages.
As a rule, in case of a successful run the exit code is equal to 0, and
in case of an error - not equal to 0. The program terminated by the user (to
prevent a critical mistake, by pressing [Ctrl-Break] or [SysReq], etc.) has
the code equal to 255. But this does not mean that any program with exit
code 255 has been expressly terminated by a user.
Usually first rate packages exit codes are described in detail in the
accompanying documents.
Thus, ERRORLEVEL is the exit code value of the program executed last.
<Number> is a number from 0 to 255.
Non-obligatory parameter <rel> is the relation described in section
"string1<rel>string2", but used here as the relation between two numerical
values of <number> and ERRORLEVEL. Its absence means that the condition is
true if the exit code is greater than or equal to <number> (i.e. ERRORLEVEL
GE <number>).
Thus, the condition is considered to be true if the relation <rel>
between the return code and <number> is true.
Example:
Suppose that PROGRAM.EXE is an executable program returning the exit
code.
.....
RUN PROGRAM.EXE
IF ERRORLEVEL GT 5 exit
IF ERRORLEVEL 2 echo Error code greater than or equal to 2.
IF ERRORLEVEL EQ 1 echo Error code equal to 2.
.....