Statement: onerr [ln num) – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual
Page 67

Operating Functions
Chapter 5
5–30
Mode: RUN
Type:
CONTROL
The ONERR[ln num]
statement lets you handle arithmetic errors, if
they occur, during program execution.
Only ARITH. OVERFLOW,
ARITH. UNDERFLOW,
DIVIDE BY ZERO and BAD ARGUMENT
errors
are “trapped” by the ONE RR statement. All other errors are
not “trapped”.
If an arithmetic error occurs after the ONE RR
statement
is executed, the module interpreter passes control to the line
number following the ONERR[ln num] statement. You handle the error
condition in a manner suitable to the particular
application. The ONERR
command
does not trap bad data entered during an input
instruction.
This yields a “TRY AGAIN” message or “EXTRA
IGNORED”
message. See Chapter 9 for an explanation of errors.
With the
ONERR[ln num] statement, you have the option of
determining what
type of error occurred. Do this by examining
external
memory location 257 (101H) after the error condition is
trapped.
The error codes are:
ERROR
CODE =10 – DIVIDE BY ZERO
ERROR
CODE =20 – ARITH. OVERFLOW
ERROR
CODE =30 – ARITH. UNDERFLOW
ERROR CODE =40 – BAD ARGUMENT
You can examine this location
by using an XBY(257) statement.
Example:
PRINT XBY(257)
or
E XBY(257)
5.4.19
Statement: ONERR
[ln num)