Intel 9800758-02 Webcam User Manual


 
BASIC-80
Error Handling
10
ON ERROR GOTO 100
20
INPUT
A
30
PRINT
521
A
40
GOTO
20
100
PRINT
"Error";ERR;"at
line";ERL
110
IF 11=ERR
THEN
PRINT
"Division
by
zero"
120
RESUME NEXT
RUN
?
13
4
? 0
Error
11
at
line
30
Division
by
zero
?
Trace Facility
The TRON and TROFF (trace
on
and trace off) commands are used to examine the
execution
of
each line. The line number of each program statement executed
is
displayed in brackets. The preceding example would run like this after entering
TRON and then RUN:
[10]
[20]? 5 (CR)
[30]
10.4
[40] [20]?
7 (CR)
[30]
7.428571
[40] [20]? 0 (CR)
[30] [100]
Error
11
at
line
30
[110]
Division
by
zero
[120] [40] [20]?
The ON
ERROR
OOTO 0 statement has a special meaning. When entered outside
of
error handling routines it disables any prior
ON
ERROR OOTO so that errors are
handled
normally-error
messages are displayed and execution
is
lialted. When
entered inside
an
error handling routine, it allows normal handling of a given error
or errors, as shown in the example below.
10
ON ERROR GOTO 100
20
INPUT
A,B
30
PRINT
AlB
40
PRINT
SQR(8-A}
50
STOP
100
IF ERR<>11
THEN
130
110
8=1
120
RESUME
130
ON ERROR GOTO 0
RUN
? 2,0
2
Illegal
function
call
in
40
Ok
The error routine (lines 100-130) sets B to 1 when the divide-by-zero error occurs,
but allows other errors to interrupt operation in a conventional way.
The non-fatal floating-point overflow and divide-by-zero errors are trapped like
other errors. No messages are displayed in this case, and the results
of
the calcula-
tions are undefined.
4-3