Hi,
This example might help you.
dim MyAry() as string
print array count(MyAry(0))
array delete element MyAry(),0
print array count(MyAry(0));" MyAry is Empty"
`not working - array insert at top
`not working - array insert at element
array insert at bottom MyAry()
MyAry() = "Hello "
print array count(MyAry(0))
array insert at bottom MyAry()
MyAry() = "World "
array insert at bottom MyAry()
MyAry() = "This "
array insert at bottom MyAry()
MyAry() = "Is "
array insert at bottom MyAry()
MyAry() = "A "
array insert at bottom MyAry()
MyAry() = "Test."
print array count(MyAry(0))
array index to top MyAry()
do
print MyAry();
next array index MyAry()
if array index valid(MyAry()) = 0 then exit
loop
print
for x = 0 to array count(MyAry())
print x; " ";MyAry(x)
next x
undim MyAry(0)
wait key
rem The Dim creates 1 element with index 0
DIM bullets(0) AS bulletType
rem The insert adds element 2 with index 1
ARRAY INSERT AT BOTTOM bullets()
rem This assigns values to element 0
rem because array count is 1 less then the total
bullets(ARRAY COUNT(bullets(0))).posX = player.posX
bullets(ARRAY COUNT(bullets(0))).posY = player.posY
bullets(ARRAY COUNT(bullets(0))).spriteNum = bsprite
Some tips
After dimming an array delete element 0 then it can easily used as a list in a loop.
if array count() = -1 then the array is empty
if array count() = 0 then the array has one element
Use the arrays internal index instead or array count.
array insert at bottom MyAry()
MyAry() = "Hello "
Some people create arrays and don't use element 0 but the list, queue, and stack functions use it.
The array,list,stack,queue all work interchangeably on any array.
I believe the only show stopper bug is inserting in the middle of an array(list).
Hope it helps
Dave...