Array key paths

Richard Gaskin ambassador at fourthworld.com
Fri Nov 22 10:17:51 EST 2013


Monte Goulding wrote:
> On 13/11/2013, at 9:38 AM, Mark Wieder wrote:
>
>> And the multidimensional array doesn't even have to be numerically
>> indexed - the split command creates a hierarchical index for the hash:
>>
>> put "hello" into tTest["abba"]["zabba"]
>> put  "abba,zabba" into tPath
>> split tPath by comma
>> -- tPath is now
>> --   [1] : "abba"
>> --   [2] : "zabba"
>> put tTest[tPath] --> "hello"
>
> Ah.. yeah... I should have made that more clear in my example... it's the path that needs to be numerically indexed.
>
> The other thing you can do is mix things up:
>
> put "hello" into tTest[1][2]["abba"]["zabba"]
> put  "abba,zabba" into tPath
> split tPath by comma
> put  1,2 into tRootPath
> split tRootPath by comma
> put tTest[tRootPath][tPath] = "hello" -- true

The part about "it's the path that needs to be numerically indexed" 
confuses me, as does Mark Waddingham's description in the RQCC request 
at <http://quality.runrev.com/show_bug.cgi?id=7166>:

     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.

In my brief experiments it seems the path key array works like any other 
array, in that it's an associative array so that it makes no difference 
whether the key is numeric or a string, since the under-the-hood 
representation is still a string.

Given this, Mark's 3) above is something I'm not seeing.

What am I not understanding?

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