Commodore VIC-20 User Manual page 135

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

NEXT
The NEXT statement is always used in conjunction with the FOR
statement. When the program gets up to a NEXT statement, it goes
back to the FOR statement and checks the loop. (See FOR statement
for more detail.) If the loop is finished, execution proceeds with the
statement after the NEXT statement. The word NEXT may be followed
by a variable name, or a list of variable names, separated by commas.
If there are no names listed, the last loop started is the one being
completed. If the variables are given, they are completed in order form
left to right.
EXAMPLE:
10 FOR L = 1 TO10:NEXT
20FORL = 1 TOiOrNEXTL
30 FOR L = 1 TO 10:FOR M = 1 TO 10:NEXT M,L
ON
This command can make the GOTO and GOSUB commands into
special versions of the IF statement. The word ON is followed by a
formula, which is evaluated into a number. The word GOTO or GOSUB
is followed by a list of line numbers separated by commas. If the
result of the calculation is 1, the first line in the list is executed. If the
result is 2, the second line number is executed, and so on. If the result
is 0, negative, or larger than the list of line numbers, the next line
executed will be the statement following the ON statements.
EXAMPLE:
10 INPUT X
20 ON X GOTO 10,50,50,50
30 PRINT "NOPE!"
40 GOTO 10
50 PRINT"YUP!"
60 ON X GOTO 10,30,30
125

Advertisement

Table of Contents
loading

Table of Contents