Re: Impossible "If"?
Re: Impossible "If"?
- Subject: Re: Impossible "If"?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 11 May 2001 12:27:43 -0700
On 5/11/01 10:00 AM, "Andy Bachorski" <email@hidden> wrote:
>
The above repeat statement will cause the count command to be executed for
>
each iteration of the repeat statement. Not (too) big of a issue in the
>
above case where the list is a local variable. But consider the following
>
>
tell app "Finder"
>
repeat with i from 1 to count of files in someFolder
>
set anItem to file i of someFolder
>
-- do something
>
end repeat
>
end tell
>
>
In this script, a count command will be sent to the Finder for each
>
iteration of the repeat loop. Depending on how many items are in the
>
folder, this could significantly slow down the script. Better to count once
>
before the repeat.
No, apparently that's not true, Andy. It only counts once, before doing the
repeat loop. So it does the same thing as your previous version. I agree
with you that it's simpler to use this method because it always works, so I
always use it for repeat loops myself instead of the 'repeat with x in
someList' method.
--
Paul Berkowitz