6-6 HP IBASIC Supplement
Debugging Programs
Displaying the Last Error Encountered
Displaying the Last Error Encountered
It is sometimes useful to review the last error encountered by a program
that is being run. This is done from the command line by examining the
value assigned to the variable name ERRM$. This value will include the
error number and message of the last error encountered by the program.
An additional method of displaying the error message is to use an error
trapping subroutine.
For example, insert the following line at the beginning of a program.
ON ERROR GOSUB Errormsg
The subroutine Errormsg should then be included at the end of the
program (after execution is stopped but before the END command).
100 Errormsg:!
110 DISP ERRM$
120 PAUSE
130 RETURN
The error message is automatically shown on the display line of the
IBASIC window and program execution is paused when an error
message is encountered.
You may also encounter SCPI errors in addition to IBASIC errors. SCPI
errors can occur when a command syntax is unrecognized or incorrect.
For more details on SCPI errors, refer to the Programmer's Guide.