ProSoft Technology MVI56-BAS User Manual
Page 68
Using the Program Port (PRT1)
MVI56-BAS ♦ ControlLogix Platform
User Manual
BASIC Module (DB/BAS Compatible)
Page 68 of 234
ProSoft Technology, Inc.
December 13, 2011
120
Invalid battery backed RAM location.
121
Second STRING value is invalid.
122
Unknown error
Syntax:
ONERR [line number]
Two new commands have been added to help programmers:
ERRLINE
and
ERRCODE
.
ERRLINE
PUSHes the offending line number onto the argument stack.
ERRCODE
PUSHes the offending error code onto the argument stack.
The following shows an example of how to use the
ONERR
command:
10 ONERR 100
20 LET = 5
30 PRINT "THIS IS LINE 1"
40 PRINT "THIS IS LINE 2"
50 PRINT "THIS IS LINE 3"
60 END
100 PRINT "ERROR CODE WAS ", ERRCODE
110 PRINT "ERROR LINE WAS ", ERRLINE
120 END
Ready
>run
ERROR CODE WAS 16
ERROR LINE WAS 20
Lines 30 to 60 are skipped and the program execution continues at line 100.
Alternatively, the XBY function can be used:
10 ONERR 100
20 LET = 5
30 PRINT "THIS IS LINE 1"
40 PRINT "THIS IS LINE 2"
50 PRINT "THIS IS LINE 3"
60 END
100 PRINT "ERROR CODE WAS ", XBY(257)
110 PRINT "ERROR LINE WAS ", ( 256*XBY(27133) + XBY(27134) )
120 END
Ready
>run
ERROR CODE WAS 16
ERROR LINE WAS 20
Note: The values passed as arguments to the
XBY
function in the above example are the only valid
variable locations. All other variable locations will return 0.
XBY()
can also be used on the left side of the equal sign; this assigns a value to any of the above
variable locations, overriding the automatically generated error information. Again, the variable
locations used in the above example are the only ones that can be accessed. Any other variable
locations will cause an error.
If you wish to store and retrieve user values in battery-backed SRAM, use the
XBYTE
function (see
Operators and Statements).