Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>errorlevel()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ERRORLEVEL()


Syntax:     ERRORLEVEL([<expN>])

Purpose:    To return the current Clipper exit code if one has been set
            and optionally set the exit code to a new value.

Argument:   <expN> is the new exit code setting.  This can be a
            value between zero and 65,535.

Returns:    An integer numeric value.

            ERRORLEVEL() returns the current Clipper exit code if one
            has been set using ERRORLEVEL() with an argument; otherwise
            it returns zero.

Usage:      ERRORLEVEL() is primarily designed to use with SWITCH.EXE in
            order to chain execution of application programs.  As an
            example, assume you have a main application program and,
            depending on some condition, it needs to execute another
            .EXE file.  You can do this by setting the error level just
            before exiting to DOS as follows:

            IF choice = "ONE"
               err_lev = 1
            ELSEIF choice = "TWO"
               err_lev = 2
            ELSEIF choice = "THREE"
               err_lev = 3
            ENDIF
            ERRORLEVEL(err_lev)        && Set error level.
            QUIT

            You then execute SWITCH from the DOS prompt specifying the
            list of executable application programs corresponding to
            error levels specified in the shell program.  For example:

               C>SWITCH ONE TWO THREE

Notes:     . ERRORLEVEL() is not updated when a child process
             terminates.  To obtain this information you must create an
             assembler or C routine that queries the child process exit
             code using INT 21 Function 4D.

Library:    CLIPPER.LIB


----------------------------------- Example --------------------------------

   error_level = ERRORLEVEL()       && Get current error level.
   ERRORLEVEL(1)                    && Set new error level.


See Also: CANCEL QUIT SWITCH.EXE

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson