Anyone please any ideas

Ok I have this script and it work great. But only if you have the two image files already downloaded.

display dialog "Choose Wisely." buttons ["Life", "Death"] default button 2

if button returned of result is "Death" then
	try
		tell application "Finder" to open file "Inferno.gif"
	end try
	display dialog "You Have Chosen Poorly" buttons ["I Recant", "Good"]
	if button returned of the result is "I Recant" then display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
	if button returned of result is "Here Is Thy Due Reward" then
		try
			tell application "Finder" to open file "Heaven.jpg"
			if button returned of the result is "Good" then tell application "Finder" to shut down
		end try
	else
		display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
		if button returned of result is "Here Is Thy Due Reward" then
			try
				tell application "Finder" to open file "Heaven.jpg"
			end try
		end if
	end if
end if

So thats stupid, If i would want to share this, I cant. So I want to add these two scripts to go inplace of "tell application “Finder” to open file “.jpg”
But I havent been able to get it all to work, when I change it.

The scripts I have for the change are . . .

set the target_URL to "http://www.72seconds.com/mt/archives/Busting%20into%20Heaven%20-%20(c)%20Rod%20Boothby%202005.jpg"
set the destination_file to ((path to desktop as string) & "Heaven.jpg")

tell application "URL Access Scripting"
	download target_URL to file destination_file replacing yes
end tell

tell application "Finder" to open alias destination_file

and

set the target_URL to "http://cognitivedistortion.com/img/FG85/3D/68_Inferno-Wide.jpg"
set the destination_file to ((path to desktop as string) & "Inferno.jpg")

tell application "URL Access Scripting"
	download target_URL to file destination_file replacing yes
end tell

tell application "Finder" to open alias destination_file

Thanks for any help. I really appreciate it. I never knew scripting could be so enjoyable.

Welcome to the forum Andrew!

This should work for you… I noticed some errors in your logic before so I modified the script a bit. Hopefull it’s what you’re looking for.


tell application "Finder"
	if not (exists file "Inferno.jpg") then my downloadImage("http://cognitivedistortion.com/img/FG85/3D/68_Inferno-Wide.jpg", "Inferno.jpg")
	if not (exists file "Heaven.jpg") then my downloadImage("http://www.72seconds.com/mt/archives/Busting%20into%20Heaven%20-%20(c)%20Rod%20Boothby%202005.jpg", "Heaven.jpg")
	
	if button returned of (display dialog "Choose Wisely." buttons ["Life", "Death"] default button 2) is "Death" then
		open file "Inferno.gif"
		if button returned of (display dialog "You Have Chosen Poorly" buttons ["I Recant", "Good"]) is "I Recant" then
			display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
			open file "Heaven.jpg"
		else
			shut down
		end if
	end if
end tell

on downloadImage(_url, _name)
	tell application "URL Access Scripting" to download _url to file ((path to desktop as string) & _name) replacing yes
end downloadImage

Cheers!

When clicking “Life” in the first dialog box nothing happens.

And I would really appreciate if you could maybe explain a little about what was wrong with the logic.

What should happen if you click life? When I ran your script and clicked life nothing happened for me.

Also the problem I encountered was when I did some choice (top my head, I don’t recall) you were trying to evaulate a result you didn’t have because a display dialog hadn’t happened do to prior logic evaluation.

Are you saving this as an application bundle?

My apoligizes I copied the wrong version of my script (I have like five going at the same time). When you click life its supposed to open up the Heaven.jpg.

And thanks for the explanation, I really appreciate it.

Ahh okay here you go then =)


tell application "Finder"
	if not (exists file "Inferno.jpg") then my downloadImage("http://cognitivedistortion.com/img/FG85/3D/68_Inferno-Wide.jpg", "Inferno.jpg")
	if not (exists file "Heaven.jpg") then my downloadImage("http://www.72seconds.com/mt/archives/Busting%20into%20Heaven%20-%20(c)%20Rod%20Boothby%202005.jpg", "Heaven.jpg")
	
	if button returned of (display dialog "Choose Wisely." buttons ["Life", "Death"] default button 2) is "Death" then
		open file "Inferno.gif"
		if button returned of (display dialog "You Have Chosen Poorly" buttons ["I Recant", "Good"]) is "I Recant" then
			display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
			open file "Heaven.jpg"
		else
			shut down
		end if
	else
		display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
		open file "Heaven.jpg"
	end if
end tell

on downloadImage(_url, _name)
	tell application "URL Access Scripting" to download _url to file ((path to desktop as string) & _name) replacing yes
end downloadImage

And Bruce leads to a good point

If you were going to distribute this as a application buundle rather then a script you could include the images in the bundle. (Inside the Contents:Resources folder)

tell application "Finder"
	set _path to ((path to me) as Unicode text) & "Contents:Resources:"
	if button returned of (display dialog "Choose Wisely." buttons ["Life", "Death"] default button 2) is "Death" then
		open file (_path & "Inferno.gif")
		if button returned of (display dialog "You Have Chosen Poorly" buttons ["I Recant", "Good"]) is "I Recant" then
			display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
			open file (_path & "Heaven.jpg")
		else
			shut down
		end if
	else
		display dialog "You Have Choosen Wisely." buttons ["Here Is Thy Due Reward"] default button 1
		open file (_path & "Heaven.jpg")
	end if
end tell