System Functions
ERR( ) Test Error Value
 
Format 1. Return ERR Position: ERR(compare1,compare2,...[,ERR=stmtref])
 
2. Return Extended Error Information: ERR(keyword$ | *)
 
Where:
 
* Asterisk. Lists the names of the returned values.
 
compare1, Comma-separated list of numeric values for comparison with the
compare2, ... value of the internal ERR variable.
 
keyword$ Currently supported return values:
  "ERR" Error condition
  "RET" OS error
  "OSERR" OS error message; i.e., MSG(-1)
  "PROGRAM" Pathname of program with error
  "STNO" Statement number
  "OBJ" Object number
  "METHOD" Method name invoked
  "LFA" Last file accessed
  "LFO" Last file opened
  "LASTPATH" Last pathname referenced
"LASTKEY" Record key value, only valid for Error 11's.
 
stmtref Program line number or statement label to which to transfer control.
 
Returns Integer, relative position if match found, 0 (zero) if no match found.
 
Description The ERR( ) function can be used to determine the value of the internal ERR variable or receive additional information about the last un-trapped error.
 
Format 1 Return ERR Position
 
ERR(compare_1,compare_2,...compare_n[,ERR=stmtref])
Use this format to compare the value of the internal ERR variable with a list of possible external error values. If a match is found, the function returns an integer reporting the relative position of the value which matches the value in the external ERR system variable. The function returns 0 (zero) if no match is found.
 
Example:
 
0040 ON ERR(1,11,2) GOTO 1000,1010,1110,1020
 
Possible results:
 
ERR=1 Control transfers to line 1010
ERR=11 Control transfers to line 1110
ERR=2 Control transfers to line 1020
ERR=0 No match. Control transfers to line 1000.
 
Format 2 Return Extended Error Information
 
ERR(keyword$)
 
This format provides additional information for diagnosing untrapped errors. The information returned by the ERR( ) function is not affected by errors that are programmatically trapped using a SETERR or any of the ERR=/DOM=/BSY= options.
 
Example:
 
0010 ! Display ERR(" ") return values
0020 error_handler pgn+";ErrorHandler"
0030 print 4/0
0040 stop
0050 !
0100 ! ^100
0110 ErrorHandler:
0120 print "Un-trapped error",err,":"
0130 x$=ERR("*")
0140 !
0200 ! ^100
0210 x=pos(","=x$); if x=0 then exit err
0220 print pad(x$(1,x-1),12),"= ",
0230 print ERR(x$(1,x-1))
0240 x$=x$(x+1); goto 0200
 
See Also ERR System Variable.
Error Codes and Messages