Collapse (?) An Array?
bobs at twft.com
Thu Sep 1 12:53:49 EDT 2011
No Scott you are missing a bit of information here. Try this:
put "This is a test" into theArray
put "This is a second test" into theArray
put "This is a third test" into theArray
delete variable theArray
put the keys of theArray
What you will get is:
There is no "empty slot. Now try this:
You will get empty. Referencing a nonexistent element of a nonexistant array returns empty. It does not generate an error. This is what is tripping you up.
On Sep 1, 2011, at 7:10 AM, Scott Rossi wrote:
> Recently, Richard Gaskin wrote:
>> 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.
> Yes, this is the problem. I'm storing data in array form in custom
> properties, and my problem is after a delete, the remaining elements of the
> array are not reordered.
>> 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
>> end repeat
>> put tResult
> From what you're saying, it sounds like I need to put the remaining elements
> of the array into a temporary variable and then replace the original array.
> Scott Rossi
> Creative Director
> Tactile Media, UX Design
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode