• 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: how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how?


  • Subject: Re: how?
  • From: Chris Page <email@hidden>
  • Date: Wed, 13 Jan 2010 16:59:58 -0800

On Jan 12, 2010, at 3:52 AM, Adam Morris wrote:

FYI this is a programmer's way of writing code that's partially a comment. Take a look at the repeat statement:

repeat until ValidInput = true

That means: "I'm going to keep asking the user for valid input." More experience in scripts will show you that you use this trick often: "Repeat forever until I get valid input."

Usually you'll just see "repeat until ValidInput"

It's the return statement that ends the otherwise endless loop.

And, as a comment, I find that code misleading because it implies that that test will actually be used to exit the loop, but it isn’t. I recommend changing it to just “repeat … end repeat”, which makes it clearer to the reader that the loop is exited due to some code inside the loop.

Also, I prefer to put whitespace around (above and below) return statements so that changes in flow control stand out:

if (NoRange > 2) and (NoRange < 60) then
set NoRange to NoRange as integer --Convert the player input
--Question:  Why do I need this step???? A: see page 101 “Coercion”

return NoRange -- Return the player's input

else -- Display an error message if the input is not valid


-- 
Chris Page

 The other, other AppleScript Chris

 _______________________________________________
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: how?
      • From: LuKreme <email@hidden>
    • Re: how?
      • From: Adam Morris <email@hidden>
References: 
 >Re: how? (From: Adam Morris <email@hidden>)

  • Prev by Date: Re: Time to UTC
  • Next by Date: Re: how?
  • Previous by thread: Re: how?
  • Next by thread: Re: how?
  • Index(es):
    • Date
    • Thread