PDA

View Full Version : Applescript question... looping




ethical
Aug 30, 2009, 02:25 PM
Hi guys,

I was fiddling around with applescript today, and have started leaning how to use it more to my advantage... what I'm stuck on is how to get the script to loop itself if an input it a certain value.

for example:

if a dialog box had two buttons "yes" and "no", and if the user clicked "no" a new dialog box would come up saying "Wrong answer", and would have the button "ask me again"... how do I make the script repeat itself after the user clicks "ask me again"?

I hope this makes sense.

Thanks,

Luke



larkost
Aug 30, 2009, 07:19 PM
This is a pretty simple example, but should get you going in the right direction:
set myOriginalText to "Please click Yes."
set myText to myOriginalText
repeat
set myResult to display dialog myText buttons ["Yes", "No"]
if button returned of myResult is "Yes" then
exit repeat
end if
if myText is myOriginalText then
set myText to "Wrong button pressed. " & myText
end if
end repeat

ethical
Aug 31, 2009, 07:39 PM
This is a pretty simple example, but should get you going in the right direction:
set myOriginalText to "Please click Yes."
set myText to myOriginalText
repeat
set myResult to display dialog myText buttons ["Yes", "No"]
if button returned of myResult is "Yes" then
exit repeat
end if
if myText is myOriginalText then
set myText to "Wrong button pressed. " & myText
end if
end repeat

yeah that's really helpful! Thanks for taking the time to write it out, much appreciated!!