Commodore VIC-20 User Manual page 132

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

Advertisement

You can set up loops inside one another. This is known as nesting
loops. You must be careiul to nest loops so that the later loop to start
is the earlier one to end.
EXAMPLE OF NESTED LOOPS:
10FORL=1 TO 100
20 FOR A = 5TO 11 STEP '
30 NEXT A
This for...next
loop is "nested"
inside the larger
one.
40 NEXT L
Not correct:
10 FOR L=1 TO 100
20 FOR A = 5 TO 11 STEP 2
30 NEXT L
40 NEXT A
GET
The GET statement is a way to get data from the keyboard one
character at a time. When (he GET is executed, the character that was
typed is received. If no character was typed, then a null (empty)
character is received, and the program continues. There is no need to
hit the RETURN key, and in fact the RETURN key can be received with
a GET.
The word GET is followed by a variable name, usually a string
variable. If a numeric were used and any key other than a number was
hit, the program would stop with an error message. The GET state
ment may also be put into a loop, checking for an empty result, which
will wait for a key to be struck.
(^"V~V"V-V—
example-
(
This line waits
X
> for a key to be
)
10 GET A$: IF A$ = "" THEN 10 -*—(
struck. Typing any >
7
key will continue
^
the program.
c
I
I
122

Advertisement

Table of Contents
loading

Table of Contents