Looking at Script File Formats


Script Editor can save a script in three basic file formats. When you save a new script or a copy of a script, you specify a file format by choosing the format from the Format pop-up menu in the Save dialog. Script Editor can save in the following file formats:

  • Script/Script Bundle. Saves the script as Apple event codes rather than plain text. You can open it with Script Editor and then run or change it. You can also run compiled scripts by using the Script Runner application and applications that have a script menu, such as AppleWorks. You can save scripts as run only so they can not be edited, only run.

  • Application/Application Bundle. Saves the script as an application, complete with an icon. Opening the icon (by double-clicking it, for example) runs the script. When you choose the application format, the following two options appear at the bottom of the Save dialog:

    • Run Only. Script application can not be edited, only run.

    • Stay Open. Causes the application to stay open after its script finishes running. If this option is turned off, the application quits automatically after running its script.

    • Show Startup Screen. Displays an identifying window that appears when the application is opened. The Startup screen confirms that the user wishes to run the script.

  • Text. Saves the script as a plain text document. You can open it in Script Editor, in a word processing application, and in many other applications. Although a more portable file, this format is not as efficient as the others, because the script must be compiled before it can be run.

New to AppleScript 1.9.2, the version that ships with Mac OS X.3, is the ability to save scripts as Mac OS X bundles. Cocoa applications are bundles (another name for packages) which, though they appear as a single item or application, are actually a collection of the files and resources that the application needs to run. If you control-click on a cocoa application, you can see inside of an application’s bundle by choosing Show Package Contents. You’ll see all of the necessary files and folders that make up an application’s contents. It is the concept of an application bundle that allows developers to make their applications installable via drag and drop, instead of using an installer that places files all over your computer. When you save a script as either a Script Bundle or an Application Bundle, it creates a similar package from your script, and you can control-click on your saved document and see the package contents just like any cocoa application. The differences between a bundle and a standard script or application are beyond the scope of this Chapter, and are mainly geared towards developers of applications. See the AppleScript documentation for developers on-line at http://developer.apple.com/documentation/AppleScript/ if you are interested in more information about bundles and how they can be used. Access to this documentation requires registration with the Apple Developer Connection; you can find information about ADC and sign up at http://developer.apple.com/index.html.




Mac OS X Bible, Panther Edition
Mac OS X Bible, Panther Edition
ISBN: 0764543997
EAN: 2147483647
Year: 2003
Pages: 290

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net