Program loop
FOR ControlVariable% = InitialValue% TO FinalValue% [STEP step%]
<instructions>
NEXT
The instructions are repeatedly executed in a loop. The control variable has at first the initial value and is increased in each cycle about the incrementation step, as long as the final value is not exceeded.
Control variable, initial value and final value must be of the type integer, the incremental value must be an integer constant. With STEP omitted the incrementation is 1.
Example:
sum=0
FOR i=0 to 9
sum=sum+i
NEXT
PRINT "The sum of the numbers from 0 to 9 is",sum |
|