intel MCS BASIC-52 — Intel MCS BASIC-52 Versions 1 & 1.1 Operating and Reference Manual PDF (EN)

int e l 4.18 DESCRIPTION OF STATEMENTS STATEMENT: ONERR[ln num] MODE: RUN TYPE: CONTROL The ONERR[ln num] statement lets the programmer handle arithmetic errors, should they occur, during program execution. Only ARITH. OVERFLOW, ARITH. UNDERFLOW, DIVIDE BY ZERO, and BAD ARGUMENT errors can be "trapped" by the ONERR statement, all other errors are not. If an arithmetic error occurs after the ONERR statement is executed, the MCS BASIC-52 interpreter will pass control to the line number following the ONERR[ln num] statement. The programmer can handle the error condition in any manner suitable to the particular application.

Typically, the ONERR[ln num] statement should be viewed as an easy way to handle errors that occur when the user provides inappropriate data to an INPUT statement. With the ONERR[ln num] statement, the programmer has the option of determining what type of error occurred. This is done by examining external memory location 257 (101H) after the error condition is trapped. The error codes are as follows: ERROR CODE = 10 - DIVIDE BY ZERO ERROR CODE = 20 - ARITH. OVERFLOW ERROR CODE = 30 - ARITH. UNDERFLOW ERROR CODE = 40 - BAD ARGUMENT This location may be examined by using an XBY(257) statement. - 50 -