' FOR/NEXT — Looping with STEP, EXIT FOR, ITERATE FOR
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL i AS LONG
    LOCAL line AS STRING

    PRINT "Count from 1 to 5:"
    line = ""
    FOR i = 1 TO 5
        line = line + STR$(i) + " "
    NEXT i
    PRINT line
    PRINT

    PRINT "Count down (STEP -2):"
    line = ""
    FOR i = 10 TO 0 STEP -2
        line = line + STR$(i) + " "
    NEXT i
    PRINT line
    PRINT

    PRINT "EXIT FOR at 3:"
    line = ""
    FOR i = 1 TO 10
        IF i > 3 THEN EXIT FOR
        line = line + STR$(i) + " "
    NEXT i
    PRINT line
    PRINT

    PRINT "ITERATE FOR (skip evens):"
    line = ""
    FOR i = 1 TO 10
        IF i MOD 2 = 0 THEN ITERATE FOR
        line = line + STR$(i) + " "
    NEXT i
    PRINT line

    FUNCTION = 0
END FUNCTION
