Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 44

Advertising
background image

BASIC PROGRAMMING GUIDE

2-35

ONERR

Syntax:

ONERR line number

Function:

Goes to line number on arithmetic error, bad argument, and hardware errors.

Mode:

Run

Use:

ONERR 1000

DESCRIPTION

The ONERR instruction traps arithmetic errors and hardware problems, transferring control to line number.
ONERR can be used to handle errors generated due to bad user input from and INPUT instruction. ONERR
is a GOTO, not a GOSUB. Consequently, there is no easy way to resume program execution. The control
and argument stacks are cleared so all GOSUB's, FOR-NEXT loops, etc. are cleared.

Error codes are stored at external memory location 257 (101H) and are accessed using the XBY instruction.

Code

Error

0AH (10)

DIVIDE BY ZERO

14H (20)

ARITH OVERFLOW

1EH (30)

ARITH UNDERFLOW

28H (40)

BAD ARGUMENT

32H (50)

HARDWARE

EXAMPLE

100

ONERR 1000

110

A=1/0

1000

PRINT "Error code:",XBY(257)

>run
Error code: 10

Advertising