BASIC FUNCTIONS SECTION 5. 16
ON ERROR
5.16.4 Function ON ERROR is used to catch errors which would normally give
a Basic Error message.
Syntax ON ERROR GOTO [line no]
ON ERROR GOTO 0
Exanples 10 ON ERROR GOTO 1000
20
INPUT A
30
A = SQR(A)
40 PRINT A
50
GOTO 20
1 OOO A :ABS(A)
1010 PRINT "NEGATIVE NUMBER CORRECTED"
1020 RESUME 30
This example will trap negative numbers and correct the
condition.
Remarks ON ERROR causes program execution to be diverted to an
error handling subroutine.
VER.V09F
Any error can be trapped. However, ON ERROR is
normally used for correctable errors e.g. magnitude errors
which could be. caused by operator input etc.
An ON ERROR trap must be exited by either an RESUME
statement or by ON ERROR GOTO
O which will give the normal
Basic error message,
PAGE 5 - 89