Function ErrorLevel() Foundation
Sets the return code for an Xbase++ application.
ErrorLevel( [<nReturnCode>] ) --> nLastReturnCode
The return value of ErrorLevel() is the current return code of the Xbase++ application. The default value is zero.
Using the environment function ErrorLevel(), the return code of an Xbase++ application can be retrieved and/or redefined. It works like the function Set(). This means that if <nReturnCode> is specified, the function returns the old return code and inserts the new value as the current return code. When no argument is passed, the function provides the current return code. After completion of an Xbase++ application this value can be retrieved at the operating system level using ERRORLEVEL within a batch file.
By default the return code of an Xbase++ application is 0 when the program terminates normally. If a runtime error occurs, the return code is set to 1 by the default error handling routine before the program is terminated with QUIT.
// In the example three files are shown. The first is a
// command file TEST.BAT which starts an XBASE++ application.
// called TEST.EXE. When TEST.EXE is exited using the "Y"
// key, the return code is set to 111 and SAVEDATA.EXE is
// called from the command file
@ECHO OFF
REM This is the command file TEST.BAT
REM Start Xbase++ application
TEST
IF ERRORLEVEL 111 GOTO Backup
GOTO Exit
:Backup
ECHO Start saving data
SAVEDATA
:Exit
ECHO Xbase++ application is terminated
REM *EOF* TEST.BAT
**********************
* Program: TEST.EXE *
**********************
PROCEDURE Main
? "press <Y> to save data"
?
Inkey(0)
IF Upper(Chr(LastKey())) == "Y"
ErrorLevel(111)
ENDIF
RETURN
**************************
* Program: SAVEDATA.EXE *
**************************
PROCEDURE Main
? "The data saver is running. Press a key..."
?
Inkey(0)
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.