ERRCLEAR system variable

Purpose | Return the error code of the most recent PowerBASIC run-time error.
Syntax | y = ERR ERR = ErrNum y = ERRCLEAR ERRCLEAR

Remarks

ERR and ERRCLEAR return the error code of the most recent run-time error in the current Sub, Function, Method, or Property. This number can be tested after any critical operation, so that appropriate error-handling code can be executed.

You can also assign a value to ERR. This is similar to executing an ERROR statement, except that no branch to an error trap routine is generated. Instead, subsequent tests of ERR and ERRCLEAR reflect ErrNum.

ERRCLEAR returns the error code of the most recent run-time error. In addition, it resets PowerBASIC's internal error code variable ERR to zero after you reference it. Finally, it emulates RESUME FLUSH so that no RESUME execution is needed or allowed. This ensures that the next time you test ERR or ERRCLEAR, you are guaranteed to get a zero, unless a new error has actually occurred in the interim.

ERRCLEAR can also be used as a statement to reset ERR to zero.

IMPORTANT: Be sure to study the Errors and Error Trapping.

Restrictions | Valid run-time error values are in the range 0 through 255. A value of 0 indicates no error. Attempting to set an error value (with the ERROR statement) outside of that range will convert the value to a run-time Error 5 ("Illegal function call").
See also | ERROR, ERROR$, Error Overview, Error Trapping, ON ERROR
Example | y = ERR ' sets y = ERR ERR = 6 ' sets ERR to 6 y = ERRCLEAR ' sets y = ERR and ERR = 0 ERRCLEAR ' sets ERR = 0