• 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: Thu, 14 Jan 2010 16:22:14 -0800

FWIW, here’s the original loop, which is not being used like “repeat 1 times” to provide a local scope exit.

It even sets the never-used-again validInput to false and it has a comment next to the superfluous, unused repeat-loop condition, causing even more confusion about how the loop is exited. That confusion is what led to the OP starting this thread, because it makes the code confusing and mysterious.

This code is better written with an unadorned “repeat” to make it clearer that it repeats until some test within the body of the loop returns from the surrounding handler.

On Jan 10, 2010, at 12:55 PM, Jack Schwart wrote:

on GetPlayerInput()

--This variable is used to control loop execution
set ValidInput to false

repeat until ValidInput = true -- loop until valid input is collected

--Question,:how does ValidInput switch to true???

--Prompt the player to specify the range of numbers to be used
set NoRange to text returned of (display dialog ¬
"What is the highest number that can be selected when " & ¬
"creating a lottery ticket?" default answer ¬
"44" buttons {"OK"} with title GameTitle)
--The range must be at least 3 and no larger than 59
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
display dialog "Error:  You must enter an integer value " & ¬
"between 3 and 59" with title GameTitle
end if

end repeat

end GetPlayerInput

-- 
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

References: 
 >how? (From: Jack Schwart <email@hidden>)

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