Tandy 1000 Basic Reference Manual page 233

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I BASIC Keywords
ON/GOTO
Statement
ON
n
GOTO line[,line,
... I
Looks at n and transfers program control to 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.
N
must be in the range 0 to 255. If necessary, BASIC rounds n
to an integer before evaluating it. If n is 0 or is 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.
Example
1 0 ON M I GOTO 1 5 0 ,
1 6 0 ,
1 7 0 , 1 5 0 , 1 8 0
tells BASIC to evaluate MI. If MI equals 1, BASIC branches to
Line 150; if MI equals 2, BASIC branches
to
Line 160; and so
on. If MI is outside of the range 1 to 5, BASIC either continues
with the next statement or generates an Illegal function call, as
mentioned earlier.
Sample Program
5 REM < C A P S > MUST B E ON
1 0 I N P U T "ENTER
A , B ,
o r
C,";LS
2 0 L=CISC C L S )
3 0
O N
L - 6 4 GOTO 5 0 , 6 0 ,
7 0
4 0 P R I N T "TRY
AGCI1N":GOTO
1 0
6 0 P R I N T "YOU T Y P E D ' B ' " : E N D
7 0 P R I N T "YOU T Y P E D ' C ' " : E N D
5 0 PRINT
9 1 ~ 0 ~
T Y P E D ' A ' ~ ~ : E N D
231

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents