ERROR¶
Function¶
ERROR simulates a Basic error with the advantage that it allows user defined codes. For a list of Basic error messages, see Errors And Warnings.
Syntax¶
ERROR n
where 0<n<255
Example¶
10 INPUT a,b
20 ON ERROR GOT0 100
30 IF a>b THEN ERROR 156
40 GOTO 10
100 IF ERR = 156 THEN PRINT "a>b error"
110 RESUME 10
Remarks¶
The ERROR statement neatly traps errors and forces the printing of a Basic error message. If the error number is undefined in Basic, then processing can be forced to restart at another line to print a user defined message. When ERROR is set to n, this number may be recovered with ERR, and the line number with ERL.
After a forced user error trap, a suitable RESUME command must be executed to ensure correct program operation.