' Formatted Output — Columnar output padding with SPACE$
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL i AS LONG
    LOCAL items(1 TO 5) AS STRING
    LOCAL prices(1 TO 5) AS SINGLE
    LOCAL pad AS LONG
    LOCAL line AS STRING

    items(1) = "Widget"   : prices(1) = 1.49
    items(2) = "Gadget"   : prices(2) = 24.99
    items(3) = "Sprocket" : prices(3) = 0.89
    items(4) = "Doodad"   : prices(4) = 12.50
    items(5) = "Thingy"   : prices(5) = 99.95

    PRINT "Item" + SPACE$(15) + "Price"
    PRINT STRING$(25, 45)
    PRINT
    FOR i = 1 TO 5
        pad = 20 - LEN(items(i))
        line = items(i) + SPACE$(pad) + STR$(prices(i))
        PRINT line
    NEXT i

    FUNCTION = 0
END FUNCTION
