Other Statements - Sharp MZ-700 Series Owner's Manual

Personal computer
Hide thumbs Also See for MZ-700 Series:
Table of Contents

Advertisement

2.10 Other Statements
Function
2.10.1 ON ERROR GOTO
(Abbreviated format: ON ERR. G.)
I Format
]
ON
ERROR
GOTO
Lr
Lr . . . . Destination line number (entry point of an error processing routine)
This statements causes execution to branch to line number Lr if an error occurs.
The IF ERN and IF ERL statement can be used in a trap routine starting at that line
to control subsequent processing according to the type of error and the line number
in which it occurred. Including a RESUME statement at the end of the error pro-
cessing routine makes it possible to return execution to the line at which the error
occurred. Executing an ON ERROR GOTO statement cancels the error trap line
number definied by the previous ON ERROR GOTO statement. The error trap line
number definition is also cancelled by executing a CLR statement.
2.10.2 IF ERN
Format
Function
Example
IF relational expression using ERN THEN
Lr
IF relational expression using ERN THEN
statement
IF relational expression using ERN GOTO
Lr
Lr . . . . Destination line number
This statement branches execution to the error processing (trap) routine starting at
line Lr or executes the statement following THEN when the result of <relational
expression using E R N > is true.
ERN is a special function which returns a number corresponding to the type of error
occurring. See page 159 for the error numbers.
The following shows an error processing routine beginning on line 1000 which causes
execution to branch to line 1200 if the error number is 5.
1 0
O N
E R R O R
G O T O
1 0 0 0
Declares the line number of the
error processing routine.
1 0 0 0
I F
E R N = 5
T H E N
1 2 0 0
Branches to 1200 if a string
overflow error has occurred.
96-

Advertisement

Table of Contents
loading

Table of Contents