9 error handling – Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual
Page 85
6Ć45
The effect of the first format (with no line number) is to move the
DATA statement pointer back to the first DATA statement in the
program. The effect of the second format (with the line number) is to
reset the DATA statement internal pointer to the DATA statement at
the line number specified following the RESTORE. This line number
may be specified either by an integer constant or integer expression.
There must be a DATA statement at the line number that follows the
RESTORE or the system will generate a STOP ALL error. A
RESTORE can be used at any time, not only when all the DATA
statements have been read or at the end of the data.
6.9
Error Handling
During the execution of a BASIC task, error conditions can occur
that are not severe enough to stop the task but are worth noting. All
errors that happen during execution are logged in the task error log,
accessible through the onĆline menu of the Programming Executive
software. If the error is severe, it is displayed on the two 7Ćsegment
LEDs on the Processor module (M/N 57C430, 57C430A, 57C431,
and 57C435) and all tasks are stopped. See JĆ3684, JĆ3750 or
J2Ć3045 for more information.
BASIC provides two statements to help deal with errors that occur
during execution.
1. ON ERROR statement
2. RESUME statement
6.9.1
ON ERROR Statement
The ON ERROR statement is used to define where the task should
transfer control if a nonĆfatal error occurs. The ON ERROR statement
has the following format:
ON ERROR GOTO line_number
where:
line_number = line_number where
error handling routine begins.
When BASIC executes the ON ERROR statement, it stores the line
number referenced for later reference. When an error occurs, BASIC
transfers control of the program immediately to that line number.
The ON ERROR statement may be executed as many times as
desired. BASIC reĆloads the error handler line number each time.
To tell the user what kind of error occurred and where it took place.
BASIC provides two preĆdefined symbols:
D ERR% Ć The error number of the logged error (decimal
ăerror number)
D ERL% Ć The line number where the error occurred
These symbols are automatically defined when the task is created
and can be accessed the same as any other variable. Refer to
Appendix B for a complete listing of runĆtime error codes.