dealing w/ multidimensional arrays

Rob Cozens rcozens at pon.net
Mon Oct 14 11:02:01 EDT 2002


>It seems that Rev only simulates support for multidimensional arrays 
>by concatenating the key together for you. It makes creating 
>multidimensional arrays easy.  That's great but how do you get the 
>data out, unless you know the entire concatenated array key before 
>hand? And how likely is that? Do I have to use regular expressions 
>to match my "multidimensional" array keys to access my data?

Alex,

I'm not sure this is pertinent to your problem, but it is possible to 
support non-keyed multidimensional arrays using multiple delimiter 
characters.  Three-dimensional example:

on putValue thevalue, at theArray,xcoord,ycoord,zcoord,xdelim,ydelim,zdelim
    set the itemDelimiter to xdelim
    put item xcoord of theArray into firstLevel
    set the itemDelimiter to ydelim
    get item ycoord of firstLevel
    set the itemDelimiter to zdelim
    put theValue into item zcoord of it
    set the itemDelimiter to ydelim
    put it into item ycoord of firstLevel
    set the itemDelimiter to xdelim
    put firstLevel into item xcoord of theArray
end putValue

functyion getValue theArray,xcoord,ycoord,zcoord,xdelim,ydelim,zdelim
    set the itemDelimiter to xdelim
    get item xcoord of theArray
    set the itemDelimiter to ydelim
    get item ycoord of it
    set the itemDelimiter to zdelim
    return item zcoord of it
end getValue
-- 

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