Re: Exit Repeat [Was: [Case Statements]]
Re: Exit Repeat [Was: [Case Statements]]
- Subject: Re: Exit Repeat [Was: [Case Statements]]
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 12 Feb 2002 09:17:09 -0800
On 2/12/02 7:14 AM, "email@hidden" <email@hidden>
wrote:
>
> and if you're wondering "what if I want to escape the outer repeat loop?" :
>
>
>
> set checked to false
>
> repeat -- any sort of repeat loop
>
> repeat 1 times
>
> --blah blah
>
> if something = whatever then exit repeat
>
> -- more blah
>
> if somethingElse = totallyZonked then
>
> set checked to true
>
> exit repeat
>
> end if
>
> --yet more blah
>
> end repeat
>
> if checked then exit repeat
>
> end repeat
>
>
What am I missing? Why not just
>
>
set checked to false
>
repeat while checked is false
>
if myTest is not whatIwant then
>
set checked to true
>
end if
>
end repeat
>
>
It seems to me to be the best solution for an exit repeat from within as many
>
nested ifs as you want.
>
What you're missing is that the snippet I provided allows you to BOTH:
1) Do a "Repeat next"
AND
2) Get out of the main repeat loop
as needed (either one). Two different things.
What you're providing only allows 2), not 1). You can't go on to the next
repeat iteration with that - you can only get out of the main repeat loop.
Frequently, I will want to do a repeat loop, creating a result - perhaps an
application object - on each iteration, except with some values. Under those
latter circumstances, I just want to skip an iteration and go on to the next
iteration. Then - under yet some other circumstances, i want to get out of
the repeat loop completely (like a normal 'exit repeat'). That's what I
provided. Yours can't do that.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.