Arrays: new and old keys, i

Trevor DeVore lists at mangomultimedia.com
Thu Sep 11 17:13:15 EDT 2008


On Sep 11, 2008, at 5:02 PM, Björnke von Gierke wrote:

> On 11 Sep 2008, at 22:49, Trevor DeVore wrote:
>
>> put "some string" into theValue
>> put "[people][1][name]" into theKey ## assume you didn't know the  
>> full path to the key in advance.
>> put "put theValue into theArrayA" & theKey into theDo
>> do theDo
>
> I'm not sure I understand the problem here, what prohibits the use  
> of the following way to achieve the above?
>
> on mouseUp
>  put "people" into theFirst
>  put "1" into theSecond
>  put "Name" into theThird
>  put "some string" into theArrayA[theFirst][theSecond][theThird]
> end mouseUp
>
> Besides less readability, more lines of code, etc. of course. Still  
> if you don't know what the keys will be beforehand, then you'll have  
> them individually in vars anyway, right?
>
> Probably not understanding the problem correctly

Hi Björnke,

In your example above you assume that you know there are three  
dimensions. But what if you do not know how many dimensions you will  
be referencing? When this is the case then your variable is going to  
have the full path (from 1 to x number of dimensions) but the engine  
does not have a means of using that variable to grab the keys value  
without resorting to 'do'.

And yes, there are times when having this ability is very useful.

Make sense?

Regards,

-- 
Trevor DeVore
Blue Mango Learning Systems
www.bluemangolearning.com    -    www.screensteps.com


More information about the use-livecode mailing list