Specifications
150
[ 2 ] Programming for trapping errors
To trap errors, use the ON ERROR GOTO statement in which you should designate the error-
handling routine (to which control is to be transferred if a run-time error occurs) by the label.
ON ERROR GOTO err01
.
.
.
(Main routine)
.
.
.
END
err01
(Error-handling routine)
PRINT"*** error ***"
PRINT ERR,HEX$(ERL)
RESUME NEXT
If a run-time error occurs in the main routine, the above program executes the error-handling
routine specified by the label err01 in the
ON ERROR GOTO statement.
In the error-handling routine, the
ERL and ERR functions allow you to pinpoint the address
where the error has occurred and the error code, respectively.
The
RESUME statement may pass control from the error-handling routine back to any specified
statement as listed below.
NOTE
According to the error location and error code, you should troubleshoot the program-
ming error and correct it for proper error handling.
RESUME
Statement
Description
RESUME or RESUME 0
Resumes program execution with the statement
that caused the error.
RESUME NEXT
Resumes program execution with the statement
immediately following the one that caused the
error.
RESUME label
Resumes program execution with the statement
designated by label.