Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ethical

macrumors 68000
Original poster
Dec 22, 2007
1,661
1
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

macrumors 6502a
Oct 13, 2007
534
1
This is a pretty simple example, but should get you going in the right direction:
Code:
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

macrumors 68000
Original poster
Dec 22, 2007
1,661
1
This is a pretty simple example, but should get you going in the right direction:
Code:
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!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.