Well I never!
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"]
>> 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:
> 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
> -- A "group" named "1" that has a "name" property.
> -- 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.
> The benefit of the multi-dimensional array is that you can treat each
> "group" as its own entity.
> 'put the keys of mdArray' only returns the "properties" for that
> "group". The output would be:
> Since "children" is also a "group" I can ask for its properties as
> 'put the keys of mdArray["children"]' would output:
> 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["children"]
> Do you need to extract the children "group"?
> put mdArray["children"] into theOtherMDArray
> For me the ability to target is what makes coding with arrays so much
> simpler and efficient.
> Hopefully this helps somewhat.
> Trevor DeVore
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:
I have found this in the Docs:
"Array elements may contain nested or sub-elements, making them multi-
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
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.
More information about the Use-livecode