FOR ... TO ... STEP ... NEXT |
![]() ![]() |
FOR var-assign TO limit [STEP number] statements NEXT var
FOR var-assign TO limit [STEP number] statements ENDFOR
Repeat a section of code a given number of times. The variable that acts as a counter is available within the loop. The MyBASIC2 implementation allows for the use of ENDFOR instead of the standard NEXT var syntax.
Example:
FOR i = 1 TO 10 PRINT i, NEXT i
FOR i = 1 TO 100 STEP 10 PRINT i, ENDFOR
|