EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 168

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...
s
TRS-80
MODEL
ERROR
code
Lets you
"simulate'
'
a specified
error during
program
execution.
The major
use of
this
statement is for
testing an
ON ERROR
GOTO routine.
When
the ERROR
code
statement is
encountered,
the Computer
will proceed
exactly
as if
that kind
of error
had
occurred.
Refer
to Appendix
B for
a
listing
of error
codes and
their
meanings.
Example
Program:
100
ERROR 1
READY
> RUM
?NF
Error
in
IBB
READY
1
is the error
code
for
"attempt to
execute NEXT
statement
without
a matching
FOR
statement".
See
ON ERROR
GOTO,
RESUME.
ON ERROR
GOTO
line
number
When the
Computer
encounters
any
kind of
error in your
program,
it normally
breaks
out of execution
and
prints
an error
message.
With ON
ERROR
GOTO, you
can
set up
an error-trapping
routine which
will allow
your program
to
'
'recover"
from
an error
and
continue
,
without
any
break in
execution
. Normally
you have
a
particular
type of error
in mind
when
you use
the ON
ERROR
GOTO
statement.
For
example,
suppose your
program
performs
some
division
operations
and you have
not
ruled
out
the
possibility
of division
by
zero. You
might want
to write
a routine
to
handle
a division-by-zero
error, and
then
use ON
ERROR GOTO
to branch
to
that
routine
when
such an
error
occurs.
Example:
10 ON
ERROR GOTO 100
20 A
=
1 /
90 END
100 PRINT-ERROR
#
"?
ERR/2
+
1
110 RESUME
90
In
this
"loaded"
example,
when
the
Computer
attempts
to
execute
line
20, a
divide-by-zero
error
will occur.
But
because
of line
10, the
Computer will
simply
ignore
line
20
and
branch
to the
error-handling
routine
beginning
at line
100.
NOTE:
The ON
ERROR
GOTO
must
be executed
before
the
error occurs
or
it will
have
no
effect.
158

Other manuals for Radio Shack TRS-80 Model III

Related product manuals