Quotes Required Around Keys in 2 Dimensional Arrays?

Rob Cozens rcozens at pon.net
Tue Apr 16 10:45:01 EDT 2002


>but
>there is one piece of the puzzle where passing multi-dimension arrays would
>be very handy..

Hi Shao Sean,

Is there some reason the following won't work for you?

>You can also set up arrays of three dimensions or more using 
>multiple delimiters:
>
>From my post of 7 Jan, 2002:
>
>>>
>function getElement xCoord,yCoord,zCoord,xDelim,yDelim,zDelim,zaArray
>   put the itemDelimiter into savedDelimiter
>   set the itemDelimiter to zDelim
>   get item zCoord of zaArray
>   set the itemDelimiter to yDelim
>   get item yCoord of it
>   set the itemDelimiter to xDelim
>   get item xCoord of it
>   set the itemDelimiter to savedDelimiter
>   return it
>end getElement
><<

Pare it down to two elements, write a putElement function to reverse 
the process, and you're in business.

For simple two-dimensional arrays of numbers (also text if there are 
no imbedded commas), one can simply reference elements by item and 
line.  Eg: myArray[4,55] is "item 4 of line 55 of myArray".

BTW, I believe I have seen some statements to the effect that it is 
not necessary to save & reset the itemDelimiter in RunRev because the 
itemDelimiter setting in the handler does not persist after the 
handler quits as it does in HyperTalk.  Can anyone confirm or refute 
that?
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list