Radio Shack TRS-80 PC-3 Owner's Manual page 131

Table of Contents

Advertisement

1 FOR
2 FOR
numeric variable
=
expression 1 TO expression 2
numeric variable
=
expression 1 TO expression 2
STEP expression 3
Abbreviations: F. and FO.; STE.
See also: NEXT
Purpose
The FOR verb is used in combination with the NEXT verb to repeat a series of operations a specified number of times.
Use
The FOR and the NEXT verbs are used in pairs to enclose a group of statements which are to be repeated. The first time this
group of statements is executed the loop variable (the variable named immediately following the Fa R) has the value of expression
1.
When execution reaches the NEXT verb, this value is tested against expression 2. If the value of the loop variable is less than or
equal to expression 2, the loop variable is increased by the step size and the enclosed group of statements is executed again, starting
with the statement following the FOR. In the first form, the step size is 1; in the second form, the step size is given by expression
3. If the value of the loop variable is greater than expression 2, execution continues with the statment which immediately follows
the NEXT. Because the comparison is made at the end, the statements within a Fa R/N EXT pair are always executed at least once.
Expression
and expression 2 may have any value in the numeric range. When expression 1 and expression 2 are compared, only
111

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents