ERR/ERL

Function

ERR and ERL return the error code and the line number at which the error occurred respectively.

Syntax

X = ERR

Y = ERL

Example

10 GOTO 50
20 A = ERR
30 PRINT "Error Number";A;"at line";ERL
50 ON ERROR GOTO 20
60 B=A/0
70 STOP

This example prints:

Error Number 6 at line 60

due to the floating point error caused by an attempt to divide by zero.

Remarks

ERR and ERL will always contain the codes of the last error, and will often be used in conjunction with ERROR.

These functions are often used in communications with the ON...ERROR...GOTO trap.

See Errors And Warnings for actual error numbers.

ERR defaults to zero until an error occurs.