Specifications

Commands - 79
ON ERR GOTO
Statement
SYNTAX: ON ERR GOTO line/label
PURPOSE: To enable error trapping and specify the first line of the error handling subroutine.
REMARKS: Once error trapping has been enabled, all errors detected by CAMBASIC during run time cause
CAMBASIC to branch to the specified line.
To disable error trapping, execute an ON ERR without the line number. If the routine beginning at
line has an error, an infinite loop will be set up. In this case, do a hardware reset and execute the
UNNEW! command. The error trapping subroutine should be tested before executing an ON ERR
statement.
The ON ERR GOTO line statement must be performed every time an error occurs if you wish to
continue to trap on errors. The best place to do this is in the error handling routine.
RELATED: RESUME, RESUME NEXT
EXAMPLE: 10 ON ERR GOTO 100
20 A=5/0
30 END
100 PRINT "DIV BY ZERO"
110 ON ERR GOTO 100
120 RESUME NEXT
In this case just using RESUME without the NEXT would cause line 20 to be executed again,
producing another error.
10 ON ERR GOTO : 'disable error trapping
ERROR: <Can’t compile> – if line/label does not exist