The Directory Walker revisited
wouter
wouter.abraham at pi.be
Wed Sep 3 12:59:01 EDT 2003
See below...
On woensdag, sep 3, 2003, at 15:07 Europe/Brussels,
use-revolution-request at lists.runrev.com wrote:
> Message: 11
> Date: Wed, 03 Sep 2003 06:53:13 -0700
> Subject: Re: The Directory Walker revisited
> From: Scott Rossi <scott at tactilemedia.com>
> To: <use-revolution at lists.runrev.com>
> Reply-To: use-revolution at lists.runrev.com
>
snip
> Here's one from the archives that works for me (added a simple busy
> cursor
> indicator):
>
> global gHierList
> on mouseUp
> put empty into gHierList
> put empty into field 1
> answer folder "Pick a folder you want to walk:"
> if it is empty then exit mouseUp
> set lockCursor to true
> set cursor to watch
> directoryWalk it
> sort gHierList
> put gHierList into field 1
> put number of lines of fld 1
> set lockCursor to false
> end mouseUp
>
> on directoryWalk whatFolder
> set the defaultFolder to whatFolder
> put the files into temp
> repeat for each line x in temp
> put whatFolder & "/" & x & return after gHierList
> end repeat
> put the folders into tDirList
> repeat with x = 2 to the number of lines of tDirList
> directoryWalk (whatFolder & "/" & (line x of tDirList))
> end repeat
> end directoryWalk
>
> I believe the script posted on Ken Ray's tips site (which is also in
> the
> archives) will run into the recursion limit problem. Ken - maybe you
> can
> update your tips page with a revised script.
>
> Regards,
>
> Scott Rossi
> Creative Director
>
> Tactile Media, Multimedia & Design
> Email: scott at tactilemedia.com
> Web: www.tactilemedia.com
>
I am very sorry to inform you that this one you adapted from David
Vaughn, is also bumping into the recursionLimit.
So as everybody is really liking recursive handlers I cooked something
up which you could call a recursive handler (as it is calling itself).
And which will NOT run into the recursionLimit by allowing it to end
itself before starting a new instance of itself. Here it is :
local lDirList,lHierList
on mouseUp
put "" into fld "Result"
answer folder "Pick a folder you want to walk:"
if it = "" then exit mouseUp
put it & "/" into tMainFolder
set the itemDel to "/"
put "" into lDirlist
put "" into lHierList
directoryWalk tMainFolder
end mouseUp
on directoryWalk tDir
set the directory to tDir
put tDir & cr after lHierList
if the hilite of btn "theFiles" then
put the files into temp
repeat for each line x in temp
put tDir & x & cr after lHierList
end repeat
end if
put line 2 to -1 of the folders into tTempDirList
repeat for each line x in tTempDirList
put tDir & x & "/" & cr after lDirList
end repeat
put line 1 of lDirList into tDir
delete line 1 of lDirlist
#### comment out -- in 0.5 millisecs and it will run into the
recursionLimit #####
if tDir <> empty then send "directoryWalk" && tDir to me in 0.5
millisecs
else
sort lHierlist
put lHierlist into fld "result"
put the number of lines in fld "result"
end if
end directoryWalk
Try commenting out the "in 0.5 millisecs" and see what happens. And
please use a disk with wide (and/or deep) enough directories to run a
test :^)
The added benefit of this one is that it will kind of run in the
background without locking up Revolution/Metacard.
Greetings to you all,
WA
More information about the use-livecode
mailing list