What is a script bundle?

Can someone explain what a ‘script bundle’ is? What is the difference between this and a compiled script?

Thanks.
SA :smiley:

Here’s what the release notes for AppleScript 1.9.2 have to say.

In addition to embedded scripting additions, I suspect that one could include any support files that might be needed by the script, as well as a unique identifier.

– Rob

Right.

I read that little blurb (which by the way, is the only mention of script bundles on the site), but I do not know enough about bundles? What is a bundle? What is the purpose of a bundle? What do they mean by adding scripting additions to the bundle? Is this where you would put a script that your script would use when it is run (i.e. an object or library or class, whatever programming terminology you wish to use) like jave does with multiple classes?

I guess I should have been more detailed in my question. But if this is a new technology for applescript, shouldn’t they have explained it a little more in their applescript documentation?

Thanks.
SA :smiley:

I’m not in a position to experiment with, or comment with authority on, script bundles (still using Jaguar). I assume that they are similar to, or the same as, packages. If you control-click on the icon of one of the Apple apps (Address Book, iCal, etc.) and choose “Show Package Contents” from the contextual menu, you can get an idea of the structure.

I can’t offer anything else on the topic (sorry) and I share your desire for a detailed explanation. :slight_smile:

– Rob

Well, there is not a specific explanation about the topic… A bundle is a bundle. A “folder” where you can find the usual stuff: a “Info.plist” file containing info about the bundle (the app), a “PkgInfo” file containing the file and creator type of the bundle, a “MacOS” folder containing an executable archive and a “Resources” folder, where you keep all other stuff: icons, scripts, scripting additions, localizable files, etc.
If you control-click plus choose “show package contents” lots of applications (eg, Apple’s stuff), you will find the same structure.
Specifically, the main script is stored in the “Scripts” folder (within “Resources”) and you can also create a “Scripting Additions” folder to keep osaxen, which will be loaded at run-time and will be a available to your script, though it is not installed in your system (~/Library/ScriptingAdditions and other regular locations).

If you look at the script Dial Number that I recently uploaded to ScriptBuilders, you can control-click the script icon (it was saved as an application bundle) to show the bundle contents. You can see that I added a resource file called “Dial Tones.rsrc” in the “Resouces” folder of the “Contents” folder. When the script is run, I use this line to access the file:

set tone_file to (path to me as string) & "Contents:Resources:Dial Tones.rsrc"

In this way you could add sounds, text files, libraries or any type of support file that your script would need and keep it all in a tidy package–a bundle! The application always knows where these files are and the user doesn’t have to worry about installation.

This exactly the kind of data I was looking for.

Thank You. I’m no newbie to applescript, but I am no expert either. And when I read books and documentation on Applescript (1.9.2), it is kind of frustrating that Apple has not explained this further. This seems like a feature that now adds a lot of power to applescript and it is totally glossed over everywhere I look.

How would you add an picture to this to change the icon image of the script?

Thank You all for your help.

SA
:smiley:

Just replace the “/Contents/Resources/applet.icns” with your own icon, then add a unique identifier in the “CFBundleSignature” entry within the “/Contents/Info.plist” file. Never tried, but this should work.
(perhaps you should also replace “aplt” or “dplt” with your new signature at the “PkgInfo” file)