So, I've been trying to work on this function to compress this array I've designed into the smallest space possible.
So, for example:
Array
1=[Nothing]
2=[Nothing]
3=[Nothing]
4=Banana
5=[Nothing]
6=[Nothing]
7=Apple
Would become
1=Banana
2=Apple
Thus saving space and allowing me to remove items from any point along the array as long as I run compression afterwards.
Running it with strings, I thought this would work:
FUNCTION list_compress()
FOR t=0 TO GET ARRAY INDEX(pack$())
FOR a=0 TO (GET ARRAY INDEX(pack$())-1)
IF pack$(a)=""
pack$(a)=pack$(a+1)
CLEAR ARRAY ITEM pack$(),a+1
ENDIF
NEXT a
NEXT t
ENDFUNCTION
It should work for any length of pack$(). However, when placing a string in the 10th position, it doesn't move up the queue. Before this, my problem was it was copying endlessly. Any ideas as to a solution?
Oh, to avoid confusion, "t" is only to rerun the algorithm a set number of times.