Recursion script which doesn't?
Recursion script which doesn't?
- Subject: Recursion script which doesn't?
- From: Charles Arthur <email@hidden>
- Date: Tue, 3 Apr 2001 18:47:17 +0100
Hi ...
Maybe I'm not understanding how recursive subroutines should work, but I'm
getting some very odd ones with this one (which is meant to look through a
group of folders finding files newer than a particular date, for later
copying). (This is what thefilelist is meant to become.)
I find that when I choose a folder just containing files that it returns
errors where the variable "afolder" seems to have retained its value into
the recursion, rather than being parked for a new iteration of the
recursion. Hence the various dialogs added to the script, to find out where
it is and what it's operating with.
The variable "afolder" isn't declared as a global; and I just tried
changing its name to "afol". No dice.
Also sometimes get an error entering the subroutine: "--> Finder got an
error: User canceled out of wait loop for reply or receipt." Er, no I
didn't.
I also found it confusing trying to work out how to coerce aliases to
items; if there's a more elegant way, I'm all ears and typing fingers.
Applescript 1.4, OS Z-904. Slaps with the cluestick welcome.
Charles
--tried, tested and bewildered
set lastrundate to date "Thursday, December 14, 2000 12:00:00 am"
set afolder to choose folder
comparefiles(afolder)
on comparefiles(afolder)
set thefilelist to {}
tell application "Finder"
activate
display dialog "Begin"
if class of afolder is alias then set afolder to (item afolder)
if class of afolder is folder then
activate
display dialog "It's a folder"
set theitems to every item of afolder
repeat with anitem in theitems
display dialog "recursion: " & anitem as string
my comparefiles(anitem)
set thefilelist to thefilelist & the result
end repeat
else -- afolder must be a file, right?
--display dialog class of afolder
display dialog afolder as string
display dialog (modification date of afolder) as string
if modification date of afolder is greater than
lastrundate then
set thefilelist to thefilelist & afolder
activate
display dialog "added one" giving up after 1
end if
end if
end tell
display dialog "here"
return thefilelist
end comparefiles
--
----------------------------
http://www.ukclimbing.com : 1000+ British crags, 350+ British climbing
walls - searchable by distance and anything else you care to think of -
with weather forecasts for every one, plus maps, articles, news and
features. Plus Britain's busiest climbing discussion boards. And there's
even a cool shop attached.