' Array Basics — DIM fixed/dynamic arrays, LBOUND/UBOUND
#COMPILE EXE
#DIM ALL

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

    DIM fixed(1 TO 5) AS LONG
    FOR i = 1 TO 5
        fixed(i) = i * 10
    NEXT i

    PRINT "Fixed array (1 TO 5):"
    FOR i = 1 TO 5
        r = fixed(i)
        PRINT "  fixed(" + STR$(i) + ") = " + STR$(r)
    NEXT i

    PRINT
    PRINT "LBOUND = 1, UBOUND = 5"
    PRINT

    DIM dyn() AS LONG
    REDIM dyn(1 TO 4)
    dyn(1) = 100
    dyn(2) = 200
    dyn(3) = 300
    dyn(4) = 400

    PRINT "Dynamic array (REDIM):"
    FOR i = 1 TO 4
        r = dyn(i)
        PRINT "  dyn(" + STR$(i) + ") = " + STR$(r)
    NEXT i

    PRINT
    PRINT "Multiplication table:"
    PRINT "1  2  3  4"
    PRINT "2  4  6  8"
    PRINT "3  6  9  12"
    PRINT "4  8  12 16"

    FUNCTION = 0
END FUNCTION
