Multi-dimensional arrays, tutorial?

Björnke von Gierke bvg at mac.com
Tue Aug 10 04:58:26 CDT 2010


Jim, your folder analogy is not correct, as this works fine:

put "mex" into foo["bar"]["tex"]
put foo["bar"]["tex"]
--yields: mex

With multiple arrays, I always run into conceptual problems (aka. brain pain) because in the example above:

foo is an array (has keys)
foo["bar"] is also an array and has keys
foo["bar"]["tex"] is not an array and contains text ("mex") --damn

I have written an advanced tutorial (read: confusing) on various uses for multidimensional arrays when having tab delimited data:
http://lessons.runrev.com/spaces/lessons/buckets/784/lessons/9678-How-do-I-convert-tab-delimited-data-into-an-array-

On 10 Aug 2010, at 10:15, Jim Ault wrote:

> I only have time for a quick hint.
> I think you need to create each node before defining the next child level.
> Kind of like 'create folder' at each level in the directory.
> When I did this a year ago I recall I used nested repeat loops and
> the array names in strings.  I built the requisite strings, then parsed them as I spun everything into all the dimensions.
> 
> put pData into the databaseArray[pCompany]
> put pData into the databaseArray[pCompany][pPerson]
> put pData into the databaseArray[pCompany][pPerson][pName]
> 
> Persistence is probably something like arrayEncode()
> 
> Use the Rev arrayEncode function to convert an array into a string so that it can be saved to a file or sent across a network.
> 
> 
> On Aug 10, 2010, at 12:53 AM, FlexibleLearning wrote:
> 
>> Can someone point me to an explanation or tutorial on using
>> multi-dimensional arrays, and specifically persistence between sessions?
>> Okay, so I'm a trifle late to the party but I am here now!
>> 
>> I am making no headway at all from such information as I can find in the dox
>> so obviously I have my fundamentals in a twist... For example 'put pData
>> into the databaseArray[pCompany][pPerson][pName] of this stack' ain't
>> co-operating.
>> 
> 
> Jim Ault
> Las Vegas
> 
> 
> 
> _______________________________________________
> 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