EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 197

Radio Shack TRS-80 Model III
274 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
BASIC
ERL
Returns
the line number in
which an error
has occurred
.
This function is
primarily
used
inside an error-handling
routine accessed by an
ON ERROR GOTO statement. If
no error
has occurred when ERL
is
called,
line number
is returned. However, if
an
error has occurred
since power-up, ERL
returns the line number
in which the error
occurred. If error occurred
in direct mode, 65535
is returned (largest
number
representable in two bytes)
.
Example
Program using ERL
10 CLEAR
10
20
ON ERROR
GOTO 1000
30 INPUT
"ENTER YOUR
MESSAGE"?
M*
40
INPUT
"NOW ENTER
A NUMBER";
N
50 Z
=
1/N
60 PRINT
"INPUT VALUES
OKAY
TRY
AGAIN TO CAUSE
AN ERROR"
70
GOTO 30
1000 IF
ERL=30 AND
(ERR/2
+
1
=
14) THEN
1040
1010
IF ERL=40 AND
(ERR/2
+1-6)
THEN 1050
1020
IF
ERL=50 AND
(ERR/2
+
1
=
H)
THEN 1060
1030 ON ERROR
GOTO
0:
RESUME
1040 PRINT
"MESSAGE TOO LONG—
10 LETTERS
MAXIMUM":
RESUME
1050
PRINT "NUMBER TOO LARGE": RESUME
1060
PRINT "DIVISION BY ZERO IN
LINE
50
ENTER
NON-ZERO NUMBER"
1070 RESUME
40
RUN the program. Try
entering
a
long message;
try entering zero
when the
program
asks for
a
number. Note that
ERL is used in line 1000
to determine
where the error
occurred so that appropriate
action may be taken.
ERR/2 +
1
Similar
to ERL, except err returns
a
value related to the code of the error rather
than
the line in which the error occurred.
It
is commonly used inside an error
handling routine accessed by an ON ERROR GOTO
statement.
See
Appendix B
,
"Error Codes."
ERR/2 + 1
=
true error
code
(true error
code
-
1)*2
=
err
Sample Program
See ERL.
187

Other manuals for Radio Shack TRS-80 Model III

Related product manuals