Array key paths
ambassador at fourthworld.com
Fri Nov 22 12:38:38 EST 2013
Peter Haworth wrote:
> On Fri, Nov 22, 2013 at 7:17 AM, Richard Gaskin wrote:
>> 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?
> I seem to remember getting an error if the keys of path key were not
> integers. Are you saying you've made it work with non-integer keys?
This test seems to work:
Script of one button to load the array:
put "bob" into gA["bob"]
put "44" into gA["bob"]["age"]
put "ted" into gA["ted"]
put "48" into gA["ted"]["age"]
Script of a second button to split a key and use it to retrieve a value:
put fld "key" into s
split s by comma
put gA[s] into fld "r"
put the result
There are two fields - the one named "key" has:
...and when I click the second button the field named "r" shows:
Nothing shows in the Message Box, so presumably there was no error.
This is what I would expect, since associative arrays usually have no
way to distinguish between numeric and non-numeric keys, since all of
them are treated as strings when they go through the hash to assign
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