A script suite file describes scriptable objects in terms of their attributes, relationships, and supported commands. You can think of a script suite file as supplying scripting information for use by Cocoa’s internal scripting support; that information can also be used by your application. “Script Terminology Files” describes the files used to store the scripting terminology that corresponds to the information in a script suite file. That terminology defines the terms actually used by scripters to control the application.
The information in a script suite file consists of a nested list of key-value pairs. Script suites are always property lists, but in addition they must conform to the format described in “The Structure of a Script Suite File.” For information on creating them, see “Creating Your Own Script Suite Files.”
Frameworks, loadable bundles, and applications that support scripting can include a script suite file as a language-independent resource. The name of the file takes the form suiteName.scriptSuite, where suiteName uniquely identifies the script suite file. An example would be MyApplication.scriptSuite.
Script suites are located in the (nonlocalized) Resources directory of an application, framework, or bundle. For example, for a framework named MyStuff.framework, the script suite file (named MyStuff.scriptSuite) would reside in MyStuff.framework/Resources/.
Listing B-1 shows the class description for the NSApplication class, taken from NSCoreSuite.scriptSuite, Cocoa's script suite file for the AppleScript Standard suite. The class description is shown as exported in “XML Property List File” format by the Property List Editor application. You can find the full version of this script suite file on your system by following the Resources symbolic link at /System/Library/Frameworks/Foundation.framework.
Listing B-1 NSApplication class from the script suite file for the Standard suite
<key>NSApplication</key> |
<dict> |
<key>AppleEventCode</key> |
<string>capp</string> |
<key>Attributes</key> |
<dict> |
<key>isActive</key> |
<dict> |
<key>AppleEventCode</key> |
<string>pisf</string> |
<key>ReadOnly</key> |
<string>YES</string> |
<key>Type</key> |
<string>NSNumber<Bool></string> |
</dict> |
<key>name</key> |
<dict> |
<key>AppleEventCode</key> |
<string>pnam</string> |
<key>ReadOnly</key> |
<string>YES</string> |
<key>Type</key> |
<string>NSString</string> |
</dict> |
<key>version</key> |
<dict> |
<key>AppleEventCode</key> |
<string>vers</string> |
<key>ReadOnly</key> |
<string>YES</string> |
<key>Type</key> |
<string>NSString</string> |
</dict> |
</dict> |
<key>Superclass</key> |
<string>NSCoreSuite.AbstractObject</string> |
<key>SupportedCommands</key> |
<dict> |
<key>NSCoreSuite.Open</key> |
<string>handleOpenScriptCommand:</string> |
<key>NSCoreSuite.Print</key> |
<string>handlePrintScriptCommand:</string> |
<key>NSCoreSuite.Quit</key> |
<string>handleQuitScriptCommand:</string> |
</dict> |
<key>ToManyRelationships</key> |
<dict> |
<key>orderedDocuments</key> |
<dict> |
<key>AppleEventCode</key> |
<string>docu</string> |
<key>LocationRequiredToCreate</key> |
<string>NO</string> |
<key>ReadOnly</key> |
<string>YES</string> |
<key>Type</key> |
<string>NSDocument</string> |
</dict> |
<key>orderedWindows</key> |
<dict> |
<key>AppleEventCode</key> |
<string>cwin</string> |
<key>ReadOnly</key> |
<string>YES</string> |
<key>Type</key> |
<string>NSWindow</string> |
</dict> |
</dict> |
</dict> |
Each scriptable class in a script suite file must have a “class description” which, in key-value form, declares the attributes and relationships of the class in terms of type and four-character code (or Apple event code). For example, the four-character code for NSApplication in Listing B-1 is the string "capp". You can read more about four-character codes in “Code Constants Used in Scriptability Information.” The primary key for a class description must be a class name such as NSApplication that identifies a real Objective-C class.
The class description also declares the AppleScript commands the class supports and specifies the superclass, if the superclass also supports scripting of its objects. In this case, the superclass for NSApplication is AbstractObject, which is the root of the scriptable class hierarchy, and corresponds to the NSObject class.
A script suite file is a text file containing key-value pairs in the form of a series of nested dictionaries, with two main categories: class descriptions and command descriptions.
A class description describes the attributes and relationships of a scriptable class. Relationships can be one-to-one or one-to-many. A class description also lists the commands a class supports and specifies whether a particular method of the class handles the command or the command’s default implementation is used to execute the command. A description of a class can designate a scriptable superclass, and thus inherit the attributes, relationships, and supported commands of that class. Class descriptions for the classes defined in an application's script suite file are instantiated by the global instance of NSScriptSuiteRegistry when it loads the application's scriptability information.
A command description defines the characteristics of an AppleScript command that the application, framework, or bundle specifically supports. This information includes the class of the command, the type of the return value, and the number and types of arguments. Many of the commands defined in the Standard suite (such as copy, duplicate, move, and so on) have default implementations in subclasses of NSScriptCommand, listed in “Subclasses for Standard AppleScript Commands.” Command descriptions for the commands defined in an application's script suite file are instantiated by the global instance of NSScriptSuiteRegistry when it loads the application's scriptability information. For more information on the script command mechanism, see “Script Commands.”
A script suite file may contain additional declarations, such as enumerations. For example, NSCoreSuite.scriptSuite contains a declaration for the SaveOptions enumeration, which defines the AppleScript values for yes, no, and ask that are used when closing a file.
The following tables describe the structure of a script suite file, including its optional and required keys.
Key | Value type or reference | Description |
|---|---|---|
“name” | Name of suite (required); the name can be placed anywhere in the definition, as long as it is a first-level element | |
“ | Four-character code for this suite (required) | |
“ | Class list dictionary (Table B-2) | optional (no classes defined by default) |
“ | Command list dictionary (Table B-7) | optional (no classes defined by default) |
“ | Synonym list dictionary (Table B-10) | optional (no synonyms defined by default) |
“ | Enumeration list dictionary (Table B-11) | optional (no enumerations defined by default) |
Key | Value type or reference | Description |
|---|---|---|
“ | Scriptable superclass; must be the name of an Objective-C class. All attributes, relationships, and supported commands are inherited and can be overridden. You can use the notation suiteName.className to designate the class. (Optional.) You can also use the | |
“ | Four-character code for this class (required) | |
“ | Property list dictionary (Table B-4) | Attributes of the class (optional) |
“ | Property list dictionary (Table B-4) | One-to-one relationships of the class (optional) |
“ | Property list dictionary (Table B-4) | One-to-many relationships of the class (optional) |
“ | Supported commands dictionary (Table B-6) | Commands supported by the class (optional) |
Key | Reference | Description |
|---|---|---|
“propertyName” | Property dictionary (Table B-5) | Definition of an attribute or relationship. attributeName should map to an instance variable of the class for which there are accessor methods. |
Key | Value type | Description |
|---|---|---|
“ | Name of class of values of this property (required) | |
“ | Four-character code for this suite (required) | |
“ | “Yes” or “No” (optional; “No” by default) |
Key | Value type | Description |
|---|---|---|
“commandName” | Name of method this class uses to implement the command or ““ if the default implementation is sufficient. commandName should be in suiteName.commandName notation if command is not in the same suite as the class. |
Key | Reference | Description |
|---|---|---|
“commandName” | Command dictionary (Table B-12) | Command definition. |
Key | Value type or reference | Description |
|---|---|---|
“ | Class of command. Set this value to | |
“ | Four-character code for this command (required) | |
“ | Four-character class constant for this command (optional; by default, is the constant for the script suite) | |
“ | Class name of result of command or “” if no result (optional; no result by default) | |
“ | Four-character code for the return type of the command. Must be present if “Type” value is assigned. Can be “****” if the return type is variable. | |
“ | Argument list dictionary (Table B-13) | Arguments of command (optional; no arguments by default) |
Key | Value type or reference | Description |
|---|---|---|
“ | Name of class for this argument (required) | |
“ | Four-character code for this argument (required) | |
“ | “Yes” or “No” (optional; “No” by default) |
Key | Value type or reference | Description |
|---|---|---|
“ | Class name for which four-character code is a synonym. |
Key | Reference | Description |
|---|---|---|
“enumerationName” | Enumeration dictionary (Table B-12) | One per enumeration. |
Key | Value type or reference | Description |
|---|---|---|
“ | Four-character code for this enumeration (required) | |
“ | Enumerators list dictionary (Table B-13) | Enumerators in the enumeration (required) |
Key | Value type or reference | Description |
|---|---|---|
“enumeratorName” | Four-character Apple event code for this enumerator (required) |
Last updated: 2008-03-11