Well I never!
Trevor DeVore
lists at mangomultimedia.com
Fri Mar 27 08:18:33 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"]
>
> I said to myself, So THIS must be the two dimensional arrays I've
> heard about.
>
> Now silly me, I've been using
>
> oneDimenArray[i,j]
>
> Which I suppose now must be one dimensional arrays where the keys
> are lists of two parameters. (But it sure looks like the two
> dimensional arrays I held near and dear to my heart, low these many
> years.)
>
> Little help please:
>
> What is the relative advantages of:
>
> aArray ["a"] ["b"]
>
> and
>
> bArray ["a", "b"]
>
> And what are the keys of aArray?
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
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Developer Resources: http://revolution.bluemangolearning.com
More information about the use-livecode
mailing list