Applescript question... looping

Discussion in 'Mac Programming' started by ethical, Aug 30, 2009.

  1. ethical macrumors 68000

    Joined:
    Dec 22, 2007
    #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
     
  2. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #2
    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
     
  3. ethical thread starter macrumors 68000

    Joined:
    Dec 22, 2007
    #3
    yeah that's really helpful! Thanks for taking the time to write it out, much appreciated!!
     

Share This Page