Tandy 1000 Basic Reference Manual page 231

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I BASIC Keywords
ONIGOSUB
Statement
ON n GOSUB
Zine[,Zine,
...
I
Looks at n and transfers program control to the subroutine indi-
cated by the nth line listed.
For example, if n equals 1, BASIC branches to the first line
listed; if n equals 2, BASIC branches to the second line listed.
Line
is the subroutine line at which execution begins when
BASIC makes the branch.
N
must be a number in the range 0
to
255. If necessary, BASIC
rounds
n
to an integer before evaluating it. If n is 0 or greater
than the number of line numbers listed, BASIC continues with
the next statement. If n is negative or is greater than 255, an
"Illegal function call" error occurs.
Use the RETURN statement to exit the subroutine.
Example
1 0 ON Y GOSUB 1 0 0 0 ,
2 0 0 0 ,
3 0 0 0
If Y equals 1, BASIC branches to a subroutine, beginning
at
Line 1000. If
Y
equals 2, BASIC branches to a subroutine, be-
ginning at Line 2000. If
Y
equals 3, BASIC branches to a sub-
routine, beginning at Line 3000.
If Y is outside the range 1 to 3, BASIC either continues with the
next statement or generates an "Illegal function call," as men-
tioned earlier.
229

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents