Collapse (?) An Array?
ambassador at fourthworld.com
Thu Sep 1 09:54:26 EDT 2011
Scott Rossi wrote:
> If I script this:
> put "A" into theArray
> put "B" into theArray
> put "C" into theArray
> And then script this:
> delete variable theArray
> I essentially get an array with entries that look like this:
> How can I collapse (?) the array after deleting element 2 so that the array
> only has two elements remaining?
The delete is fine; the problem is in the display of the results.
If you use:
put theArray &"*"&theArray &"*"& theArray
...you'll get the empty entry for theArray. The variable theArray
still exists, but there's nothing in that slot.
Building the output from the keys of the array will get what you want:
put the keys of theArray into tKeys
sort lines of tKeys -- if the order is important
repeat for each line tKey in tKeys
put "*"& theArray[tKey] after tResult
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
LiveCode Journal blog: http://LiveCodejournal.com/blog.irv
More information about the Use-livecode