' Array Manipulation — INSERT/DELETE/REVERSE/SWAP/SHIFT/UNIQUE
#COMPILE EXE
#DIM ALL

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

    DIM nums(1 TO 6) AS LONG
    nums(1) = 10
    nums(2) = 20
    nums(3) = 30
    nums(4) = 40
    nums(5) = 50
    nums(6) = 60

    line = ""
    FOR i = 1 TO 6
        line = line + STR$(nums(i)) + " "
    NEXT i
    PRINT "Original:        " + line

    ARRAY INSERT nums, 3, 99
    line = ""
    FOR i = 1 TO 7
        line = line + STR$(nums(i)) + " "
    NEXT i
    PRINT "INSERT 99 at 3:  " + line

    ARRAY DELETE nums, 5
    line = ""
    FOR i = 1 TO 6
        line = line + STR$(nums(i)) + " "
    NEXT i
    PRINT "DELETE at 5:     " + line

    ARRAY REVERSE nums
    line = ""
    FOR i = 1 TO 6
        line = line + STR$(nums(i)) + " "
    NEXT i
    PRINT "REVERSE:         " + line

    ARRAY SWAP nums, 1, 6
    line = ""
    FOR i = 1 TO 6
        line = line + STR$(nums(i)) + " "
    NEXT i
    PRINT "SWAP 1 and 6:    " + line

    DIM a2(1 TO 5) AS LONG
    a2(1) = 5
    a2(2) = 3
    a2(3) = 5
    a2(4) = 2
    a2(5) = 3

    ARRAY SORT a2
    ARRAY UNIQUE a2
    line = ""
    FOR i = 1 TO 3
        line = line + STR$(a2(i)) + " "
    NEXT i
    PRINT "SORT+UNIQUE:     " + line

    FUNCTION = 0
END FUNCTION
