• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Silly repeat question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Silly repeat question
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Silly repeat question (From: Alex Zavatone <email@hidden>)
 >Re: Silly repeat question (From: Nathan Greenstein <email@hidden>)
 >Re: Silly repeat question (From: Emmanuel LEVY <email@hidden>)
 >Re: Silly repeat question (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Silly repeat question
  • Next by Date: Re: Silly repeat question
  • Previous by thread: Re: Silly repeat question
  • Next by thread: Re: Silly repeat question
  • Index(es):
    • Date
    • Thread