Split command key order

J. Landman Gay jacque at hyperactivesw.com
Mon Feb 28 23:59:28 EST 2005


On 2/28/05 7:13 PM, Raymond E. Griffith wrote:

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

I get something different, but more on that below.

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

That's what I needed verified. Thanks. I was pretty sure this was the 
case, and I haven't ever seen arrays behave any differently till now, 
but was hoping to blame my problems on something other than my own 
scripts. ;) I will start digging, since the problem is obviously on my side.

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

I've heard they are based on a hash table rather than alphabetic. Here 
are the first few lines of the keys in my array :

286
35
287
36
288
37
300
290
289
38
301
291
39
40
302
292
41

etc.

 >
 > If you are using word-based key names, as myArray[textfont], then the
 > alphabetic return will indeed appear to be random.

Same hash table, I think.

Anyway, thanks for the verification on split, it helps. I'm now off to 
the debugging chamber.


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list