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

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

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

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

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

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

    FUNCTION = 0
END FUNCTION
