9 - 2 9 - 2
MELSEC-Q
9 THE CONCEPT OF ERROR HANDLING
9
9.2 How to Determine the Type of Error and the Location where the Error Occurred
The type of error and the line number where it has occurred can be determined by
using the following two functions in the error handling routine.
• ERR function Gives the error code for the generated error.
ERR
The ERR function is used to determine
the type of generated errors.
• ERL function
Gives the line number where the error occurred
ER L
The ERL function is used to determine the line of
the program where the error occurred.
The ERR function gives the type of error as an error code. See the error code table in
Appendix 5.4 for the correspondence between the error type and error code.
The generated error can be determined in detail by combining the ERR and ERL
functions.
The error handling routine is branched according to these functions, in order to perform
the correct processing for the generated error.
Example
5 ON ERROR GOTO 100
10 INPUT "X=" ;X
20 INPUT "Y=" ;Y
30 A=EXP (X) :PRINT "EXP (X)=" ;A
40 B=10^Y :PRINT "10^Y=" ; B
50 END
100 IF ERR=6 AND ERL=30 THEN
PRINT "Choose a smaller X"
110 IF ERR=6 AND ERL=40 THEN
PRINT "Choose a smaller Y"
120 RESUME 10
RUN
X=?100
Y=?2
"Choose a smaller X"
X=?2
Y=?2
EXP (X)=7.38906
10^Y=100
OK
This is the judgment when an
Overflow error occurs at line 30.
This is the judgment when an
Overflow error occurs at line 40.