ANN: GLX2 3.0.10

Richard Gaskin ambassador at fourthworld.com
Sun Aug 5 17:59:15 EDT 2012


Alejandro Tejada wrote:

> Richard Gaskin wrote
>>
>> This may help:
>>
>> function MergeArray pSourceA, pDeltaA
>>    -- Merges the elements in the array pDeltaA with
>>    -- the array pSourceA, returning an array which
>>    -- contains the values of pDeltaA for any key
>>    -- which is also in pSourceA, and any keys in
>>    -- pDeltaA which are not in pSourceA are added:
>>    --
>>    repeat for each key tKey in pDeltaA
>>      put pDeltaA[tKey] into pSourceA[tKey]
>>    end repeat
>>    return pSourceA
>> end MergeArray
>>
>
> Great! This will be really helpful:-D
> How could I do the same with elements
> of the same Array?

I'm not sure I follow, since the keys of an array will be unique so 
there will be no opportunity to find matching keys within the same array.

If you just want matching values maybe you could write a loop that walks 
through each element and turns that element into a hash with sha1Digest 
to use as a key in the resulting array.

Two issues there, though:

1. I think using nulls in array keys may be verboten, so you'd probably 
want to run the sha1 hash through base64Enode to use as a key.

2. You'll have to decide how to handle the original key names.  They'll 
be lost in this method, but if the point is to consolidate values 
regardless of key maybe the key name doesn't matter.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the use-livecode mailing list