skip lists

Dick Kriesel dick.kriesel at mail.com
Tue May 14 02:09:50 EDT 2013


On May 12, 2013, at 6:18 PM, Peter Haworth <pete at lcsql.com> wrote:

> A few months back, there was a great post that revealed what I think is a
> little known way to reference array keys - if I'm not mistaken it was from
> Dick Kriesel.  I have no idea how (in)efficient it might be compared to the
> other methods mentioned but here's the technique again.
> 
> Basically, you can supply a numerically keyed array as the key of an array.
> So, in the example of getting all the keys between N and M, with N=10 and
> M=15, you would build an array, let's call it tKeyA, with the following
> keys and values:
> 
> 1 -10
> 2- 11
> 3- 12
> 4- 13
> 5- 14
> 6- 15
> 
> To get those key values from an array tDataA, "put tDataA[tKeyA] into
> tFilterA".  

Hey, Pete.  Thanks for the credit, but when I try that expression, tDataA[tKeyA], on that data, it's empty.  

That expression, however, would be good for accessing node tDataA[10][11][12][13][14][15][16], if you had one.

For the convenience of the curious, here's what Mark Waddingham wrote:

    This is on the list to include for the next version. In that version with:
      put tValue into tArray[tKey]
    (indeed anywhere you can currently do tArray[tKey])

    The meaning of 'tKey' will be extended:
      1) If it is a string then it is as it is now
      2) If it is a numerically keyed array starting at 1, then it will mean:
           put tValue into tArray[tKey[1]][tKey[2]]...[tKey[n]]
         where <n> is the number of elements in tKey
      3) Otherwise it is an error.

    This will allow you to construct an array containing the path to the key you
    want to modify/fetch/delete dynamically.

For the convenience of the inquisitive, the thread's in the use-list archive for March, '12.

-- Dick



More information about the use-livecode mailing list