Directory Walker revisited
Dar Scott
dsc at swcp.com
Wed Sep 3 19:54:01 EDT 2003
On Wednesday, September 3, 2003, at 06:11 PM, David Vaughan wrote:
> get the folders
> repeat for each line x in it
> if char 1 of x <> "." then
> put walkDir(dirPath & "/" & x) after tList
> end if
> end repeat
...
> I use this on folders within the user volume and on small (few GB)
> external volumes. Search depths noted were up to about 10 in those
> cases (I added some code to display the maxDepth). I believe that
> total frame space, affected by repeat and if statements as Dar notes,
> will impose limits if you try it on a large volume including Apps and
> the OS folders.
That about 700 was a handler. A function is hit harder. I tested with
a function with a repeat and an if and got about 400 (on OS X with IDE
with Revolution 2.1).
BTW, what this means is that the above function might be more resistant
to recursion problems if the "." lines are stripped before the loop.
This suggests a way to get around the 'if' impact in typical recursive
functions: put the terminating return in the 'if' body and put the
recursion afterward.
I have seen something strange. The length of the error text given to
the catch varies by a factor of 1 to 20 each time. The lines are
repeated, of course, but the repetition seems to be wrong.
I'm a tiny bit worried that hitting the recursion limit with the
directory walker might be indicative of something surprising that is
going to jump up and bite me later.
Dar Scott
More information about the use-livecode
mailing list