Well I never!

James Hurley jhurley0305 at sbcglobal.net
Sat Mar 28 00:55:46 EDT 2009


>
> On Mar 27, 2009, at 2:47 AM, James Hurley wrote:
>
>> Watching the web demo today I witnessed a funny thing. It looked
>> like this
>>
>> twoDimenArray ["stuff"] ["moreStuff"]
>>
>> [Snip]
>>
>> And  what are the keys of aArray?
>

> Trevor DeVore wrote:

> I'm going to take a stab at an analogy comparing an array to
> Revolution objects and see if that helps. If it doesn't then pretend I
> never made it :-)
>
> Think of an old array as a button. You could have one button but you
> could not place a button inside another button. In the old syntax you
> had one button with many properties. For example if you were storing
> two records in an array, each with a "name" property, then it might
> look like this:
>
> oneDimenArray[1,"name"]
> oneDimenArray[2,"name"]
>
> With the introduction of multi-dimensional arrays you can think of an
> array as a group. The nice thing about a group is that it can have its
> own properties and a property can also be another group with its own
> properties.
>
> -- A "group" named "1"  that has a "name" property.
> mdArray[1]["name"]
>
> -- A "group" named "1" that has a  "name" property and another   
> "children" group.
> -- The children group has a group named "1" with a "name" property.
> mdArray[1]["name"]
> mdArray[1]["children"][1]["name"]
>
> The benefit of the multi-dimensional array is that you can treat each
> "group" as its own entity.
>
> 'put the keys of mdArray[1]' only returns the "properties" for that
> "group". The output would be:
>
> name
> children
>
> Since "children" is also a "group" I can ask for its properties as  
> well:
>
> 'put the keys of mdArray[1]["children"]' would output:
>
> 1
>
> So what is the benefit? For me it is the ability to target any of the
> "groups" in the array like you would an object in Revolution. Do you
> just need to delete the children "group"?
>
> delete local mdArray[1]["children"]
>
> Do you need to extract the children "group"?
>
> put mdArray[1]["children"] into theOtherMDArray
>
> For me the ability to target is what makes coding with arrays so much
> simpler and efficient.
>
> Hopefully this helps somewhat.
>
> Regards,
>
> -- 
> Trevor DeVore
>
>


Trevor,

Thank you for this thoughtful (and thought provoking) response.

But you give me too much credit. I apparently haven't grasped even  
the fundaments. For example I do not understand what is expressed in:

"mdArray[1]["Children"][1]["Name"]

I have found this in the Docs:

"Array elements may contain nested or sub-elements, making them multi- 
dimensional.
This type of array is ideal for processing hierarchical data  
structures such as trees or
XML. To access a sub-element, simply declare it using an additional  
set of square
brackets.
put "ABC" into myVariable["myKeyName"][“aChildElement”] "

Which suggests a structure and notion which is quite different from  
the example you gave. Why not just mdArray["Children"]["Name"] .  
Where does the "1" do for you?

You must be sorry you started this. As you can see I am at a loss. I  
am stuck back in an era when arrays were just tensors.

And I feel it is not unfair to say that the documentation has not  
caught up with this new feature of Run Rev. But I understand. It is  
so much more fun to do stuff than explain it.

Jim Hurley







More information about the use-livecode mailing list