Arrays: new and old keys, i

Jim Ault JimAultWins at yahoo.com
Fri Sep 12 12:11:11 EDT 2008


Hi, John,
I don't have 3.0 yet, but this is my take on multidimesional arrays & Rev

Associative arrays use keys that have to be unique.
Multidimensional arrays, the keys have to be unique at each level
    arr[primary][secondary][tertiary]
    arr["same"]["same"]["same"]  -- is allowed
    arr["bird"]["robin"]["male"]
    arr["bird"]["seagull"]["male"]
    arr["party"]["attendees"]["female"]["Jerri"]

 add more key combinations in the same array variable and the number of key
levels do not have to be uniform.

--create an array for the square footages of a house
put 150 into HouseSqftArr[bedroom][master]
put 125 into HouseSqftArr[bedroom][guest]
put 135 into HouseSqftArr[bedroom][second]

-- more intricate is to put the 'sqft' as a key
--  then add more primary keys (paint color, flooring,..)
put 150 into HouseArr[sqft][bedroom][master]
put 125 into HouseArr[sqft][bedroom][ guest]
put 130 into HouseArr[sqft][bedroom][ second]

--using a single array for cataloging home parameters
put "cream" into HouseArr[paint color][bedroom][ master]
put "celery" into HouseArr[paint color][bedroom][ guest]
put "yellow" into HouseArr[paint color][bedroom][ second]
put "blue" into HouseArr[paint color][kitchen][ trim]
put "oyster" into HouseArr[paint color][kitchen][ wall]

put "60x42" into HouseArr[window size][kitchen][west wall]
put "60x32" into HouseArr[window size][kitchen][south wall]
put "60x60" into HouseArr[window size][dining room][south wall]

put "hardwood" into HouseArr[flooring][dining room]

put 2 into HouseArr[walk in closet][count]
put 12 into HouseArr[walk in closet][master bdrm][width]
put 8 into HouseArr[walk in closet][master bdrm][length]
put 8 into HouseArr[walk in closet][guest bdrm][width]
put 8 into HouseArr[walk in closet][guest bdrm][length]
put "overflowing" into HouseArr[walk in closet][master bdrm][status]
put "12%" into HouseArr[walk in closet][master bdrm][husband's portion]
put "82%" into HouseArr[walk in closet][master bdrm][wife's portion]
put "2%" into HouseArr[walk in closet][master bdrm][misc storage portion]
-------------------------------------
put HouseArr[walk in closet] into closetOnlyArr
put HouseArr[paint color] into allRoomsPaintOnlyArr
put HouseArr[paint color][bedroom] into bdrmPaintOnlyArr
 
--------------------------------------
put HouseArr[sqft] into sqftArr
put 0 into totalArea
repeat for each key KY in the keys of sqftArr
        add sqftArr[KY] to totalArea
end repeat



On 9/11/08 10:50 PM, "John Vokey" <vokey at uleth.ca> wrote:

> 
> On 11-Sep-08, at 7:24 PM, use-revolution-request at lists.runrev.com wrote:
> 
>> On Sep 11, 2008, at 5:55 PM, Björnke von Gierke wrote:
>> 
>>> 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?
>> 
>> Sure. One thing that the ability to dynamically specify a key would do
>> is open up additional algorithms. Let's take the XML for example.
>> 
>> T
> ... ellipsis intentional
> 
> Can anybody explain what the new array format provides that the old
> did not?  All these bizarre examples seem not so much as exemplifying
> the ``new'' features as to leave me baffled as to what added value
> they provide.  In NONE of the supposed or alleged examples have I seen
> anything I could not do with old arrays.  So, and I mean in really
> simple language (not OOP-speak), wtf is up with these new arrays?  I
> see nothing but extra brackets.
> 
> 
> --
> Please avoid sending me Word or PowerPoint attachments.
> See <http://www.gnu.org/philosophy/no-word-attachments.html>
> 
> -Dr. John R. Vokey
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list