Split command key order
Raymond E. Griffith
rgriffit at ctc.net
Mon Feb 28 20:13:57 EST 2005
> I know that the "combine" command will yield a list that is not in any
> particular order. However, I always thought the "split" command would
> split out the keys in the order of the original list.
Actually there *is* an order with the combine command. The order, however,
is alphabetic instead of numeric, even though the keys are numerically
indexed.
So a list of 11 items that you split, as
put "1,2,3,4,5,6,7,8,9,10,11" into myArray
split myarray by comma
does indeed get indexed as myArray[1] = 1, myArray[2] = 2, etc. myArray[11]
= 11.
>
> I am getting some odd results on this though. Most of the time it works,
> but some of the time I appear to get a random order. Before I start
> debugging the problem -- which could very well be in my scripts
> somewhere -- I was wondering if anyone else has noticed whether the
> split command can give non-ordered keys?
The keys are returned in an alphabetic order, not a numeric order. The
return order would be
1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9.
If you are using word-based key names, as myArray[textfont], then the
alphabetic return will indeed appear to be random.
>
> I am not providing a secondary delimiter to the split command. I want
> the split data to give me a numbered array with key 1 being the first
> line of the original list, key 2 the second line, etc.
Understood. You can return the array manually. It is a headache, but it is
what I had to do.
Regards,
Raymond E. Griffith
More information about the use-livecode
mailing list