AppleScript Dialog

Discussion in 'Mac Programming' started by NecroDayz, Apr 21, 2014.

  1. NecroDayz macrumors newbie

    Joined:
    Feb 25, 2013
    #1
    So I want to make a complex dialog with text + variable but I cant figure it out:(

    Code:
    Code:
    if possibility is equal to "You find something" then
    		set actionsomething to display dialog "What now?" buttons {"Examine", "Nothing"}
    		set actionsomething to button returned of actionsomething
    		if actionsomething is equal to "Examine" then
    			set actionexamine to some item of {"Gold", "Strange Object"}
    			if actionexamine is equal to "Gold" then
    				set amount to random number from 1 to 100
    				display dialog "You found" and amount and "Gold"
     
  2. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    Your code snippet seems to be missing a few lines - each multiple line if statement needs to be balanced with an end if.

    The and keyword is a boolean operator - the string concatenation operator is the ampersand (&), so your statement would be something like:

    Code:
    display dialog "You found " & amount & " Gold"
     
  3. NecroDayz thread starter macrumors newbie

    Joined:
    Feb 25, 2013
    #3
    Thanks for the help, the missing end ifs are just me forgetting to copy them
     
  4. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #4
    display dialog doesn't return text. This works:

    Code:
    if possibility is equal to "You find something" then
    	set actionsomething to button returned of (display dialog "What now?" buttons {"Examine", "Nothing"})
    	
    end if
    if actionsomething is equal to "Examine" then
    	set actionexamine to some item of {"Gold", "Strange Object"}
    end if
    
    if actionexamine is equal to "Gold" then
    	set amount to random number from 1 to 100
    	display dialog "You found " & amount & " Gold"
    end if
    
     

Share This Page