Get the members of a group

Tim Jones tolistim at me.com
Wed Apr 25 12:38:09 EDT 2012


On Apr 25, 2012, at 9:31 AM, Michael Doub wrote:

> Can someone explain what is going on here?   This works:
> 
> Put the number of graphics of me into count
>   repeat with i =  count down to 1
>      if the short name of graphic i of me is not "TreeBG" then
>         delete graphic i
>      end if
>   end repeat
> 
> This does not:
> Put the number of graphics of me into count
>   repeat with i =  1 to count
>      if the short name of graphic i of me is not "TreeBG" then
>         delete graphic i
>      end if
>   end repeat
> 
> Why is the order significant?]

As you delete, you're reducing the "count" of items and once you've deleted an item, you increment the step to that + 1.  This results in skipping every other item and then overflowing the count since you've deleted items out from under yourself.  By counting backwards, you keep things sane.

Tim





More information about the use-livecode mailing list