This predefined variable is obsolete. Use the ErrorSystem class for error handling in DataFlex.
Refer to the If command for properly structured If .. Else statements.
To return the number of the last error triggered in the program.
lasterr
Each time an error is triggered, the number of the error is moved to lasterr.
You can use it with an if command to help recover from specific errors in specific places in a program.
In a place in a program where a particular error is likely to be caused by a particular program, you can provide a custom prompt to appear if that error is triggered in that place:
if lasterr eq 81 showln "RUN REINDEX"
In this example, if the value of lasterr is 81 when this line is executed, the message RUN REINDEX will be displayed on the highest unused screen line available.
Similarly, if the occurrence of a particular error in a particular place requires specific program action, that action can be provided by a command executed conditionally on the value of lasterr:
if lasterr eq 23 goto retry
In this example, if the number of the last error triggered is 23 when this line is executed, execution goes to the label retry.
The number of triggered errors depends on either of two things: (a) the number (1 through 100) of the internally set DataFlex error; or (b) the number given as the argument of an error command executed as a consequence of program action. Error commands are provided by the programmer to trigger error-handling action under circumstances not covered by the DataFlex errors. The DataFlex errors cannot be altered, and although their action can be suppressed with the on error gosub command, their being triggered will still change lasterr.