SUB ArrayInsert (Array() AS LONG, Element AS LONG, Value AS LONG)
DIM M AS QMEMORYSTREAM
M.Position = 0
M.SaveArray(Array(LBOUND(Array)), Element-1)
M.Write(Value)
M.SaveArray(Array(Element), UBOUND(Array) - Element)
M.Position = 0
M.LoadArray(Array(LBOUND(Array)), UBOUND(Array)+1)
END SUB
DIM A(1 TO 100) AS LONG
A(1) = 10
A(2) = 20
A(3) = 30
A(4) = 40
A(5) = 50
A(6) = 60
ArrayInsert(A, 3, 99)
FOR I = 1 TO 7
PRINT A(I)
NEXT
PRINT: PRINT "Press any key to continue..."
DO: LOOP UNTIL INKEY$<>""
|