Arrays: new and old keys, i
Björnke von Gierke
bvg at mac.com
Thu Sep 11 17:55:19 EDT 2008
Now I understand, I didn't consider not to tell rev how many sub
arrays there would be. I have no clue when this would be useful
though, maybe you can explain that?
At first I wanted to write an example function that uses the
paramCount, so it would automatically fill the array in a switch (at
some point you do know what the max subarray count would be). But
that'd be way too complex, and you'd need one for putting, and one for
getting, so they'd suddenly be a kind of strange cprops. Using do is
certainly the simplest way, but if you really care for speed, maybe
such a function could be useful, despite the complexity?
This is a rather interesting topic to me :D
On 11 Sep 2008, at 23:13, Trevor DeVore wrote:
> 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?
--
official ChatRev page:
http://bjoernke.com/runrev/chatrev.php
Chat with other RunRev developers:
go stack URL "http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev"
More information about the use-livecode
mailing list