Do you have a way to explain it more?

Tom,


First & easiest: One can construct a three dimensional array with words, items, and lines: word z of item y of line x of myArray = myArray[x,y,z].

Of course this supposed the contents of myArray do not include space, comma, or return. And this will not work for arrays with empty elements, as an empty word is non sequitur in xTalks.

Something more robust and supporting more dimensions would go along the lines of:

on setArrayValue @theArray,theValue,dimension1,dimension2,dimension3,dimension4
        put numToChar(28) into dimension1Delimiter
        put numToChar(29) into dimension2Delimiter
        put numToChar(30) into dimension3Delimiter
        put numToChar(31) into dimension4Delimiter
        set the itemDelimiter to dimension1Delimiter
        put item dimension1 of theArray into firstDimension
        set the itemDelimiter to dimension2Delimiter
        put item dimension2 of firstDimension into secondDimension
        set the itemDelimiter to dimension3Delimiter
        put item dimension3 of secondDimension into thirdDimension
        set the itemDelimiter to dimension4Delimiter
        put theValue into item dimension4 of thirdDimension
        set the itemDelimiter to dimension3Delimiter
        put thirdDimension into item dimension3 of secondDimension
        set the itemDelimiter to dimension2Delimiter
        put secondDimension into item dimension2 of firstDimension
        set the itemDelimiter to dimension1Delimiter
        put firstDimension into item dimension1 of theArray
end setArrayValue

function theArrayValue @theArray,dimension1,dimension2,dimension3,dimension4
        put numToChar(28) into dimension1Delimiter
        put numToChar(29) into dimension2Delimiter
        put numToChar(30) into dimension3Delimiter
        put numToChar(31) into dimension4Delimiter
        set the itemDelimiter to dimension1Delimiter
        put item dimension1 of theArray into firstDimension
        set the itemDelimiter to dimension2Delimiter
        put item dimension2 of firstDimension into secondDimension
        set the itemDelimiter to dimension3Delimiter
        put item dimension3 of secondDimension into thirdDimension
        set the itemDelimiter to dimension4Delimiter
        return item dimension4 of thirdDimension
end theArrayValue

A couple of notes:

If I used multi-dimension arrays to any extent, I would refine the above:

* Dimension delimiters could be passed or stored in a local or global variable

* Handlers could be generalized to handle as many dimensions as are passed to them

* The logic seems to me a prime candidate for recursion.

Note that if one is dealing with numeric arrays (ie: content is limited to "0" - "9", plus "." & "-"), all other characters are available as delimiters; so one could in theory support numeric arrays of over 200 dimensions.
--


Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.net/who.htm
2
"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)
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to