' DO/LOOP — WHILE, UNTIL, WHILE/WEND variants
#COMPILE EXE
#DIM ALL

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

    PRINT "DO WHILE (entry check):"
    i = 1
    outLine = ""
    DO WHILE i <= 5
        outLine = outLine + STR$(i) + " "
        i = i + 1
    LOOP
    PRINT outLine
    PRINT

    PRINT "DO UNTIL (exit check):"
    i = 1
    outLine = ""
    DO
        outLine = outLine + STR$(i) + " "
        i = i + 1
    LOOP UNTIL i > 5
    PRINT outLine
    PRINT

    PRINT "DO LOOP WHILE (exit check):"
    i = 1
    outLine = ""
    DO
        outLine = outLine + STR$(i) + " "
        i = i + 1
    LOOP WHILE i <= 5
    PRINT outLine
    PRINT

    PRINT "WHILE/WEND (classic):"
    i = 1
    outLine = ""
    WHILE i <= 5
        outLine = outLine + STR$(i) + " "
        i = i + 1
    WEND
    PRINT outLine
    PRINT

    PRINT "DO (infinite):"
    i = 1
    outLine = ""
    DO
        outLine = outLine + STR$(i) + " "
        i = i + 1
        IF i > 5 THEN EXIT LOOP
    LOOP
    PRINT outLine

    FUNCTION = 0
END FUNCTION
