Re: Silly repeat question
Re: Silly repeat question
- Subject: Re: Silly repeat question
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 26 Aug 2010 16:30:50 -0400
On Thu, Aug 26, 2010 at 3:32 PM, Alex Zavatone <email@hidden> wrote:
> Hmmm. This doesn't seem much better than an if/then statement to check a condition. Is it? Am I missing something?
You're missing the ability to leave the loop in the middle without
having to bury the rest of it in an else clause. Consider this:
repeat while someCondition
do something one
if bailout1 then
set someCondition to false
else
do something two
if bailout2 then
set someCondition to false
do something three
if bailout3 then
set someCondition to false
do something four
end if
end if
end if
surprise!
end repeat
versus this:
repeat while someCondition
do something one
if bailout1 then
exit repeat
end if
do something two
if bailout2 then
exit repeat
end if
do something three
if bailout3 then
exit repeat
end if
do something four
end repeat
You can continue to add decision points without your loop body walking
off the right of the page. Plus you don't have surprises like the
"surprise!" in the first example, which gets executed even if you hit
the first "bail out" point.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden