Re: repeat problem
Re: repeat problem
- Subject: Re: repeat problem
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 25 Sep 2001 11:32:53 -0700
On 9/25/01 11:19 AM, "Steve Suranie" <email@hidden> wrote:
>
but if I throw in the if statement I get an error message stating it can't
>
get the last item of folder...blah, bah, blah.
>
>
Why won't the loop work with the if statement?
Once you move items out of the folder, there are no longer the same number
of items any longer. In fact, if you move, say, item 3, then when you look
at item 4, you are actually looking at the original item 5 and skip the
original item 4 completely. And if there were originally 10 items, there is
no longer an item 10 (only items now), so you'll get that error when you
try to get item 10.
One way to avoid this problem is instead of:
repeat with i from 1 to itemCount
do
repeat with i from itemCount to 1 by -1
Do this whenever you are moving or deleting items from a list or collection
of items. Then you won't have any problems. (When you move item 3, seventh
from end, item 2 will still be in place.)
--
Paul Berkowitz