Important: The information in this document is obsolete and should not be used for new development.
About Scripts and Scripting Components
A script is any collection of data that, when executed by the appropriate program, causes a corresponding action or series of actions. The Open Scripting Architecture (OSA) provides a standard mechanism that allows users to control multiple applications with scripts written in a variety of scripting languages. Each scripting language has a corresponding scripting component. Each scripting component supports the standard scripting component routines described in the chapter "Scripting Components" in this book.When a scripting component executes a script, it performs the actions described in the script, including sending Apple events to applications if necessary. Like other components that use the Component Manager, scripting components can provide their own routines in addition to the standard routines that must be supported by all components of the same type.
Scripting components typically implement a text-based scripting language based on Apple events. For example, the AppleScript component implements AppleScript, the standard user scripting language defined by Apple Computer, Inc. This book uses AppleScript examples to demonstrate how applications can interact with scripting components.
Other scripting components may support the standard scripting component routines in different ways. Scripting components need not implement a text-based scripting language, or even one that is based on Apple events. For example, specialized scripting components can play sounds, execute XCMDs, or perform almost any other action when they execute scripts.
This chapter describes three ways that you can take advantage of the OSA:
Users of scriptable applications can execute scripts to perform tasks that might otherwise be difficult to accomplish, especially repetitive or conditional tasks that involve multiple applications. For example, a user can execute an AppleScript script to locate database records with specific characteristics, create a series of graphs based on those records, import the graphs into a page-layout document, and send the document to a remote computer on the network via electronic mail. When a user executes such a script, the AppleScript component attempts to perform the actions the script describes, including sending Apple events when necessary.
- You can make your application scriptable, or capable of responding to Apple events sent to it by a scripting component. An application is scriptable if it
- Responds to the appropriate standard Apple events as described in the chapter "Responding to Apple Events" in this book.
- Provides an Apple event terminology extension (
'aete'
) resource describing the Apple events that your application supports and the user terminology that corresponds to those events. The'aete'
resource allows scripting components to interpret scripts correctly and send the appropriate Apple events to your application during script execution.
- You can make your application recordable--that is, capable of sending Apple events to itself to report user actions to the Apple Event Manager for recording purposes. After a user has turned on recording for a particular scripting component, the scripting component receives a copy of every subsequent Apple event that any application on the local computer sends to itself. The scripting component records such events in the form of a script.
- You can have your application manipulate and execute scripts with the aid of a scripting component. To do so, your application must
- Use the Component Manager to open a connection with the appropriate component.
- Use the standard scripting component routines described in the chapter "Scripting Components" to record, edit, compile, save, load, or execute scripts.
To respond appropriately to the Apple events sent to it by the AppleScript component, the database application in this example must be able to locate records with specific characteristics so that it can identify and return the requested data. These characteristics are described by an object specifier record that is part of an Apple event supported by the application. Also, the other applications involved must support Apple events that manipulate the data in the ways described in the script. Each application in this example must also provide an
'aete'
resource describing the Apple events that the application supports and the user terminology that corresponds to those events, so that the AppleScript component can interpret the script correctly.Even with little or no knowledge of a particular scripting language, users of applications that are recordable as well as scriptable can record simple scripts. More knowledgeable users may also wish to record their actions as scripts with recordable applications and then edit or combine scripts as needed.
An application that uses scripting components to manipulate and execute scripts need not be scriptable; however, if it is scriptable, it can execute scripts that control its own behavior. In other words, it can perform tasks by means of scripts and allow users to modify those scripts to suit their own needs.
The next three sections provide an overview of the way scripting components can interact with applications.
Subtopics
- Script Editors and Script Files
- Scripting Components and Scriptable Applications
- Scripting Components and Applications That Execute Scripts