Chapter
10
I
BASIC Keywords
ON
ERROR
GOTO
Statement
ON
ERROR
GOTO
line
Transfers control to
line
if an
error
occurs.
This lets your program recover from an error and continue exe-
cution. (Normally, you have
a
particular type of error in mind
when you use the ON ERROR GOTO statement.)
You must execute an ON ERROR GOTO before the error occurs.
To disable it, execute an ON ERROR GOTO
0,
which causes
BASIC to stop execution and print an error message. This is rec-
ommended for errors that are trapped and from which you can-
not recover.
Note:
If an error occurs during execution of an error-
handling routine, that error message
is
printed and
execution terminates. Error trapping does not occur
within the error handling routine.
The error-handling routine must be terminated by a RESUME
statement.
Example
10
ON
ERROR
GOTO
1500
branches program control to Line
1500
if an error occurs any-
where after Line
10.
Sample Program
See ERROR.
228