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

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

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

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

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

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

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

    FUNCTION = 0
END FUNCTION
