AppleScript dialog boxes

Discussion in 'Mac Programming' started by I'm a Mac, Apr 10, 2008.

  1. macrumors 6502

    Joined:
    Nov 5, 2007
    #1
    I am an applescripts newbie, and I want to create a dialog box with different answers for different choices. Here is my code:

    display dialog "Something" buttons {"Click Here!", "Or here"} default button "Click Here!"
    display dialog "Shouldn't you be doing something?" buttons {"Yes", "No"}


    How do I make it so that it will display a different dialog depending on whether you click yes or no?
     
  2. macrumors 6502a

    karenflower

    Joined:
    Dec 7, 2007
    #2
    Hi, here's an example of how to do that:

    Code:
    set question to display dialog "Shouldn't you be doing something?" buttons {"Yes", "No"} default button 2
    set answer to button returned of question
    
    if answer is equal to "Yes" then
    	display dialog "Do it, then!" buttons {"No thanks", "Ok"} default button 2
    end if
    
    if answer is equal to "No" then
    	display dialog "Good for you." buttons {"I know", "Really?"} default button 2
    end if
    Hope you can adapt it to your needs! :)
     

Share This Page