Re: Recursion script which doesn't?
Re: Recursion script which doesn't?
- Subject: Re: Recursion script which doesn't?
- From: Charles Arthur <email@hidden>
- Date: Thu, 5 Apr 2001 23:19:44 +0100
On Wed, 4 Apr 2001 15:23:43 +0100, Nigel Garvey <email@hidden>
wrote:
>
Charles Arthur wrote on Tue, 3 Apr 2001 18:47:17 +0100:
>
>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.)
...
>
Your script works on both my 8.6 and 9.0.4 machines if I remove the
>
'display dialogs' and 'activates' and make 'lastrundate' into a global or
>
a property.
Oh, um. I had actually copied what I posted as a chunk out of a larger
program I was part-testing; in that, lastrundate was declared as a
property, but I didn't think to do that in the test chunk.
>
However, it would be more efficient - and the logic clearer -
>
like this:
>
>
set lastrundate to date "Thursday, 14 December 2000 00:00:00"
>
set afolder to choose folder
>
comparefiles(afolder, lastrundate)
>
>
on comparefiles(afolder, lastrundate)
>
set thefilelist to {}
>
tell application "Finder"
>
set theFiles to (every file of afolder) as list
--(do stuff)
>
set theFolders to (every folder of afolder) as list
--(do recursive stuff)
My snips of Nigel's script. Yes, that is neater. I hadn't considered
splitting the task into "every file of" and "every folder of". I suppose I
was going for a more brute-force "do for every possible situation".
>
I'm not sure if using 'lastrundate' as a parameter instead of a global is
>
actually more efficient, but it's generally considered to be better
>
practice.
Could I be tedious and ask particulary why?
best
Charles
http://www.ukclimbing.com : 1,000+ British crags, 350+ British climbing walls
- searchable by distance rock type, etc, with 5-day weather forecasts for
every one - plus maps, articles, news, and the New Routes database. There's
even a cool shop attached...