Collapse (?) An Array?

Dave Cragg dave.cragg at lacscentre.co.uk
Thu Sep 1 09:16:52 EDT 2011


On 1 Sep 2011, at 13:13, Colin Holgate wrote:

> Try this in the multiline message box:
> 
> put "A" into theArray[1]
> put "B" into theArray[2]
> put "C" into theArray[3]
> delete variable theArray[2]
> put theArray[1] &"*"&theArray[2] &"*"& theArray[3]
> 
> 
> You'll see that although theArray[2] is deleted, its position is still kept. The way the dictionary describes it suggests that the element would have been removed.

I don't really see it as its position being kept. For example, this will produce 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] &"*"&theArray[7] &"*"& theArray[3]

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.)

The following suggests the array position has indeed been deleted:

put "A" into theArray[1]
put "B" into theArray[2]
put "C" into theArray[3]
delete variable theArray[2]
put the keys of theArray

Cheers
Dave



More information about the use-livecode mailing list