fornext.txt example
Warning: if you clip this code into your program, look out for possible html code slipping in.
REM FOR / STEP / NEXT GLOBAL index AS INTEGER, jindex AS INTEGER REM index will step in increments of 1, starting at 0 and ending at 10 FOR index=0 TO 10 REM - empty loops are not allowed NEXT REM index will step in increments of 2, starting at 0 and ending at 10 FOR index=0 TO 10 STEP 2 REM - "index" following NEXT is optional NEXT index REM index will step in increments of -1 starting at 0 and ending at -10 FOR index=0 TO -10 STEP -1 REM NEXT REM notice that index is tested at the beginning of a for/next loop REM so that the loop is only executed twice (index=0,4) and the final REM value of index is 8. FOR index=0 to 5 step 4 PRINT index NEXT PRINT "\010\013",index REM a FOR/NEXT loop may be exited at any time using EXIT FOR index=0 to 30000 IF index\7=0 EXIT ENDIF NEXT PRINT "\010\013",index REM FOR / NEXT loops may be nested FOR index=0 TO 10 FOR jindex=0 TO 10 PRINT "\010\013",index, jindex NEXT NEXT