Collapse (?) An Array?

Admin admin at
Thu Sep 1 09:48:45 EDT 2011


I totally get what the OP wants, code-wise, I just cannot help make
it happen, but perhaps I can put it in my terms and help someone more
knowledgeable than me help him. 

What he is saying, is that when a
variable is deleted from within the array, he needs the entire array
re-ordered (sorted) and moved up a notch to account for the now deleted

So, if A,B,C,D is the array with positions 1,2,3,4 

and you
delete array variable 2 

It will now look like this: 


and the
array numbers are now: 


He needs it to be 




The C is now 2 and the D is now 3, so on and so forth across however
large the array is. 

Now, does one simply re-write the array once the
deletion is made? 

Not sure. 

Note - if this is for a database and you
are dealing with IDs, then DO NOT RE-ORDER ANYTHING - you will break the
database (well, not literally until you do a SAVE - then you really will
break it). Just leave it as is. Databases can eventually be re-ordered
(re-indexed) once they are too large and riddled with holes, but until
then, just leave it alone. 


On Thu, 1 Sep 2011 14:27:44 +0100,
Dave Cragg wrote: 

> On 1 Sep 2011, at 14:16, Dave Cragg wrote:
It seems using any key on an existing array will produce an empty value.
(I don't know if that's how it should behave. I guess the alternative
would be throwing an error.)
> Update: it seems the array doesn't
even need to exist. This also produces the same result:
> put "A"
into theArray[1]
> put "B" into theArray[2]
> put "C" into theArray[3]
delete variable theArray[2]
> put theArray[1] &"*"&otherArray[7] &"*"&
> Cheers
> Dave
> use-livecode mailing
> use-livecode at [1]
> Please visit this url to
subscribe, unsubscribe and manage your subscription preferences:
> [2]


[1] mailto:use-livecode at

More information about the Use-livecode mailing list