346 The VIC 20
User
Guide
The END statement can provide a program with one or more.
termination points at locations other than the physical end of the program.
END statements can be used to terminate individual programs when more
than one program
is
in memory at the same time. An END statement at the
physical end of the program
is
optional. The END statement
is
used in
program mode only.
Example:
20001
END
FOR-NEXT
STEP
All statements between the
FOR
statement and the NEXT statement
are reexecuted the same number
of
times.
Format:
FOR
nvar = start TO
end
STEP
increment
[statements in loop]
NEXT[nvar]
where
nvar
is
the index
ofthe
loop.
It
holds the current loop count. nvar
is
often used
by the statements within the loop.
start
is
a numeric constant, variable,
or
expression that specifies the beginning
value of the index.
end
is
a numeric constant, variable, or expression that specifies the ending
value of the index. The loop
is
completed when the index value
is
equal
to the end value,
or
when the index value
is
incremented or decre-
mented past the end value.
increment if present,
is
a numeric constant, variable, or expression that specifies the
amount by which the index variable
is
to be incremented with each
pass. The step may be incremental (positive)
or
decremental (negative).
If
STEP
is
omitted, the increment defaults to
I.
nvar
may optionally be included in the NEXT statement. A single
NEXT statement
is
permissible for nested loops that end
at
the same point.
The NEXT statement then takes the form
NEXT nvar1,nvar
Z
•••
The FOR-NEXT loop will always be executed
at
least once, even
ifthe
beginning
nvar
value
is
beyond the end
nvar
value.
If
the NEXT statement
is
omitted and no subsequent NEXT statements are found, the loop
is
executed once.