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
.
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...