keeping keys of an array in the order they came in?

Klaus major-k klaus at major-k.de
Sat Aug 19 09:12:23 EDT 2017


Hi Mike,

> Am 19.08.2017 um 14:36 schrieb Mike Bonner via use-livecode <use-livecode at lists.runrev.com>:
> 
> Have a separate list, or a special key that holds your list of keys.
> 
> put empty into tArray
> repeat for each line tLine in tData
> put item 2 of tLine into tKey
> if tKey = EMPTY then next repeat
> put tLine & CR after tArray[tKey]
> put tKey & cr after tarray['myKeyList']
> end repeat
> 
> Then when you need to pull things back out, grab myKeyList and iterated
> through it.  (delete the trailing cr after the repeat ends of course)

thank you, will try this!

> On Sat, Aug 19, 2017 at 6:28 AM, Klaus major-k via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> 
>> Hi Jonathan,
>> 
>>> Am 19.08.2017 um 14:22 schrieb Jonathan Lynch via use-livecode <
>> use-livecode at lists.runrev.com>:
>>> 
>>> You could alter the name of the elements...
>>> 
>>> Put "X_" & tK into tArrayElement
>>> Put tData into myArray[tArrayElement]
>>> X would be created in a counting loop.
>>> 
>>> That way, when you get the keys of the array, you can sort numeric by
>> item 1 of each, using "_" as the itemdel. This will give you the original
>> order with just 1 array dimension, and you can easily retrieve the value of
>> tK.
>> 
>> not possible, I am doing something like this:
>> ...
>> put empty into tArray
>> repeat for each line tLine in tData
>> put item 2 of tLine into tKey
>> if tKey = EMPTY then next repeat
>> put tLine & CR after tArray[tKey]
>> end repeat
>> ...
>> And item 2 are these said number, so I cannot control/name the key this
>> way.

Best

Klaus
--
Klaus Major
http://www.major-k.de
klaus at major-k.de





More information about the Use-livecode mailing list