Split, combine ok but where's extract?

David Vaughan dvk at dvkconsult.com.au
Sun Feb 13 17:13:12 EST 2005

On 14/02/2005, at 4:00, Alex Tweedly <alex at tweedly.net> wrote:

> If you take the case of
>   put "1,2" into myArray[a,b]
>   put "1,3" into myarray[c,d]
> Nope. It will actually give
> v1 = a,c
> v2 = b,d
> v3 = 1
> v4 = 3     **** the other value got lost in the split immediately 
> before the assignment to v3; I don't know if it's theoretically 
> guaranteed which of the values it will give, but in practice, with few 
> entries, it will give the latter one.

Perhaps I have misunderstood the depth of the problem. I do not appear 
to have the described difficulty with the example data.
Here is code (assume a couple of testing fields, "f1" and "f2") and the 
results using your actual example data.

   put "1,2" into myArray[a,b]
   put "1,3" into myarray[c,d]
   put the keys of myArray into field "f1"
   combine myArray with return
   put myArray into field "f2"

splits the keys from the data, preserving all components, while (using 
data from the fields as created above)

   put field "f1" into tData -- the a,b \r c,d data
   put field "f2" into tKeys -- the 1,2 \r 1,3 data
   split tData with return
   put 1 into i
   repeat for each line x in tKeys
     put tData[i] into myArray[x]
     add 1 to i
   end repeat
-- and to prove it happened
   combine myArray with return and "#"
   put myArray into field "f2"

puts them back in an array. The only relevant possibility of 
duplication appears to be with the keys of the original array, which by 
definition were not duplicated anyway.

I receive the digest so discussions may be slow.


> -- 
> Alex Tweedly       http://www.tweedly.net

More information about the use-livecode mailing list