So I’ve decided to teach myself Applescript. I am trying to make a little app that opens a dialog box with two buttons. Either button opens a new dialog box, each with its own buttons, and depending on the series of buttons you’ve pressed it will perform a action. However I am having trouble getting it to work. What I have so far is
display dialog "Choose Wisely." buttons ["Life", "Death"] default button 2
try
if button returned of the result is "Death" then tell application "Finder"
activate
open document file "Inferno.gif" of folder "Desktop" of folder "Friend" of folder "Users" of startup disk
display dialog "You Have Chosen Poorly" buttons ["I Recant", "Good"]
if button returned of the result is "Good" then tell the application "Finder" to shut down
end tell
display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
try
if button returned of the result is "Here Is Thy Due Reward" then tell application "Finder"
activate
open document file "Heaven.jpg" of folder "Desktop" of folder "Friend" of folder "Users" of startup disk
end tell
end try
end try
Ok so when you click “Death” it opens the dialog box “You have chosen poorly” with the buttons “I Recant” and the indifferent “Good”.
When You click on “I Recant” it pops you back into the “You have chosen wisely” dialog box and its button “Here is thy due reward” opens the image file. But if you choose to damn yourself (so to speak) and click the button good in the dialog box “You have chosen poorly” then it initiates the shutdown, which is what I want, but it also pops you back into the “You have chosen wisely” dialog box.
I think its some sort of loop, but I dont know how to do that yet. Obviously if your indifferent and you choose “good”, you have no desire to view heaven, so your computer should shut down, and not tell you the you have chosen wisely and open up the heaven image.
Any help would be greatly appreciated. Im ready to learn.
Model: MacBook Pro
Browser: Safari 419.3
Operating System: Mac OS X (10.4)