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 :)

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).

---example script, do not use on your whole hard drive

global theArray
on mouseUp
   put "" into theArray
   answer folder ""
   if the result = "" and it <> "" then
      set the defaultfolder to it
      put it into currFolder
      put the files into theArray["files"]
      put the folders into theNodes
      filter theNodes without ".*"
      repeat for each line theLine in theNodes
         put addChild(currFolder, theLine) into theArray[theLine]
      end repeat
   end if
end mouseUp

function addChild parentFolder theFolder
   put parentFolder & "/" &  theFolder into currFolder
   set the defaultfolder to currFolder
   put the files into theParent["files"]
   put the folders into theNodes
   filter theNodes without ".*"
   repeat for each line theLine in theNodes
      put addChild(currFolder, theLine) into theParent[theLine]
   end repeat
   return theParent
end addChild

---end example script

On 12 Sep 2008, at 01:20, Trevor DeVore wrote:

On Sep 11, 2008, at 5:55 PM, Björnke von Gierke wrote:

Now I understand, I didn't consider not to tell rev how many sub arrays there would be. I have no clue when this would be useful though, maybe you can explain that?

Sure. One thing that the ability to dynamically specify a key would do is open up additional algorithms. Let's take the XML for example.

The XML conversion routines I posted earlier use recursion in order to create a multi-dimensional array from an XML document of unknown parent/child relationships. Every time the function finds children of a node the function calls itself recursively in order to process those children.

--

official ChatRev page:
http://bjoernke.com/runrev/chatrev.php

Chat with other RunRev developers:
go stack URL "http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev";

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to