The error-handling routine must
be
terminated by a RESUME
statement. See RESUME.
Example
10
ON
ERROR
GOTO
1500
branches program control to line 1500 if
an
error occurs anywhere
after line
10.
For the use of
ON
ERROR GOTO
in
a program, see the sample
program for ERROR.
ON
...
GOSUB
Statement
ON
expression GOSUB line,
...
Calls the subroutine
at
the line based
on
the value of expression.
Expression
is a numeric expression between 0 and 255, inclusive. For
example, if
expression's value
is
three, the third line number
in
the list
is the destination of the branch.
If
expression's value
is
zero or greater than the number of items in
the list (but less than or equal to 255), BASIC continues with the next
executable statement.
If
expression
is
negative or greater than 255,
an
"Illegal function call" error occurs.
Example
ON
Y
GOSUB
1000t
2000t
3000
RETURN
RETURN
RETURN
# 1
tl
:
#3":
#2
11
:
"SUBROUTINE
"SUBROUTINE
"SUBROUTINE
If
Y =
1,
the subroutine beginning at 1000 is called.
If
Y =
2,
the
subroutine
at
2000 is called.
If
Y =
3,
the subroutine at 3000 is
called.
Sample Program
430
INPUT
"CHOOSE
1 t
2t
OR
3"
440
ON
I
GOSUB
500t
800t
700
450
END
500
PRINT
800
PRINT
700
PRINT
2-133