Arrays: new and old keys, i

Trevor DeVore lists at mangomultimedia.com
Thu Sep 11 23:13:46 EDT 2008


On Sep 11, 2008, at 8:53 PM, Björnke von Gierke wrote:

> I see now, but I'm still thinking about alternatives that make you  
> not use "do". You say your script is recursively walking trough the  
> XML. But that would allow to only use a one dimensional array  
> assignment. I tried to look at your code, but it's too hard for me  
> to understand, oh and I also hate XML, so I made a directory walker  
> example instead :)

The XML code works without using do. Since it is recursive there is no  
need for worrying about multi-dimensional keys. I actually chose the  
recursive technique because I would have had to use 'do' in order to  
use an iterative algorithm.

> Basically the code returns an array, which is put into the parent  
> array, which is then put into the parent array, which is put into  
> it's parent array, etc. Would this be applicable to your XML code?  
> Also, I am not sure how to do the reverse, to make folders out of  
> the array (creating XML).

Your function is set up pretty much like the current XML converter.

The code where I currently use 'do' deals with converting SQL columns  
and rows into a multi-dimensional array that mimics the parent/child  
relationships of the tables in the SQL query. This is slightly more  
complex then converting XML to an array since databases return flat  
results and you have to manually determine the hierarchy.

I'm calling functions recursively but I am working on a reference to  
the array that I am generating so there is no copying of data. Using  
'do' came about because you can't pass array keys by reference. So  
instead I pass a string representing the array element to act on  
instead (i.e. [1][table][2]) and use that in conjunction with 'do'.  
Once the engine allows variable references to be used with array keys  
then out comes the 'do' and I get a speed bump.

Regards,

-- 
Trevor DeVore
Blue Mango Learning Systems
www.bluemangolearning.com    -    www.screensteps.com


More information about the use-livecode mailing list