Re: Scripting Sherlock
Re: Scripting Sherlock
- Subject: Re: Scripting Sherlock
- From: Simon Forster <email@hidden>
- Date: Fri, 08 Dec 2000 16:47:22 +0000
A big thank you to Chris Nebel for his comments with regards to improving my
repeat statement. My original script took 6 minutes 12 seconds to run when I
timed it just now, this has been trimmed to 58 seconds by changing a couple
of lines.
A lesson learnt.
Thank you.
Simon Forster
________________________________________________
LDML Ltd, 28 Montgomery Road, London, W4 5LZ, UK
<tel int="+44 20 8995 5694" uk="020 8995 5694">
<fax int="+44 20 8995 6013" uk="020 8995 6013">
<
mailto:email@hidden>
________________________________________________
>
From: Chris Nebel <email@hidden>
...
>
> --Code snippet
>
> repeat with i in (every folder of the entire contents of folder ((name of
>
> startup disk) & ":WebSTAR") whose name begins with "~")
>
> set end of folderList to (i as string)
>
> end repeat
>
> --End code snippet
>
>
Whenever you think a script is too slow, open up the event log and look at
>
what
>
it's doing. In this case, there's an oddity in how AppleScript evaluates
>
repeat loops. The "in" part gets evaluated every time through the loop, so if
>
there are n matching items, there are n "every folder..." events sent to the
>
Finder. We'd like to only evaluate "every folder..." once, so instead try
>
something like this:
>
>
set x to (every folder of the entire contents of folder "WebSTAR" ,
>
of the startup disk whose name begins with "~")
>
repeat with i in x
>
set end of folderList to i as string
>
end