Array key paths
ambassador at fourthworld.com
Fri Nov 22 16:17:51 CET 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
>> --  : "abba"
>> --  : "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["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
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][tKey]...[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?
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