Chapter 6 RAPID!
Commands
WCDMA Options Version 6.20
177
Description
If an error occurs during program execution, the program
would normally be terminated.
The
ON ERROR command structure gives you the chance
to trap the error, handle it, and then continue the pro-
gram without a break.
ON ERROR GOTO targetLabel branches to the spec-
ified label in case an error occurs.
ON ERROR GOTO 0 deactivates the error trapping. Any
subsequent error will stop the program.
RESUME continues the program with the command that
caused the error.
RESUME targetLabel continues the program at the
specified label.
RESUME NEXT continues the program with the com-
mand following the one, that caused the error.
Note: If an error occurs within the error handling, the
program will be terminated.
There are several built-in functions available for error
handling.
Examples
In the first example, the 4400 prints an error message,
giving the error code, the line in which the error occurred
and the name of the related RAPID! program file.
ON ERROR GOTO errorHandler
...
errorHandler
PRINT "Error "; ERR; " in line "; ERL;
" in file "; ERF$; " Resuming..."
RESUME NEXT
In the following example, a user-specific error code is
generated first. Then a
CASE SELECT command is used
to print the correct error message.
ON ERROR GOTO errorHandler
...
LET measQ = measNum / measRes
IF (measRes<0) THEN ERROR 57
...
errorHandler: SELECT CASE ERR
CASE 104: PRINT "Division by zero!
Restart measurement!"
CASE 57: PRINT "Measurement result
negative! Restart measurement!"
CASE ELSE
PRINT "Unknown error. Program halts."
END
END CASE
RESUME NEXT