Error opening script as application

I know enough about Applescript to write everything I need to with enough efficiency to get my application running. My problem is when I save as an application. I want to “package” my script as an application that I can open up on another computer and run. But when I run the application on a different computer, it wants to search for an icon that I have built into the application that isn’t lead to by the written path within my script. Here is the error:

File file MacintoshHD:Users:Everett:Desktop:Scheduling:Scheduling_icon.icns wasn’t found

Is there a way to “package” all of this information into my script/application? Or will I have to do without the graphics to run it on a different machine.

I know this is probably an amateurish question but it’s the last thing standing in the way of me completing this project.

Oh also I’ve read to just “Save As” an “Application Bundle” but I don’t have that option in “Save As”, only “Save As” “Application”.

Hi,

you can save a script as application bundle (in 10.7 it’s just called application).
A standard Cocoa application bundle is actually a folder covered as a bundle
and contains a folder Contents which contains several items like the binary file and required resources.

An icon is located normally in the Resources folder.

in AppleScript you can refer to the bundle (or even to a plain script) with

path to me

The (HFS) path to the Resources folder is

(path to me as text) & "Contents:Resources:"

If your icon is in the Resources folder the path is

(path to me as text) & "Contents:Resources:Scheduling_icon.icns"

OK, this is where my inexperience becomes evident. So if I have it written this way:

on run
	display dialog "Welcome to DHAT." with title "DHAT" with icon file "Macintosh HD:Users:Everett:Desktop:Scheduling:DHAT:DHAT_icon.icns" buttons {"Cancel", "Calculate Daily Hour Allotment"} default button 2

and I want that icon to represent my script once it’s packaged as an application, what do I need to amend?

Nevermind I got it. Thanks for your help.

put the icon in Contents:Resources of your bundle and use this


on run
	set iconFile to alias ((path to me as text) & "Contents:Resources:Scheduling_icon.icns")
	display dialog "Welcome to DHAT." with title "DHAT" with icon iconFile buttons {"Cancel", "Calculate Daily Hour Allotment"} default button 2
end run

if you want to share your script/app absolute paths are useless anyway

Hi.

There’s also a ‘path to resource’ command, which I presume still exists in Lion. This works with the icon in the applet’s Resources folder:


on run
	set iconFile to (path to resource "Scheduling_icon.icns")
	display dialog "Welcome to DHAT." with title "DHAT" with icon iconFile buttons {"Cancel", "Calculate Daily Hour Allotment"} default button 2
end run