Chapter 21. Scripting Additions


A scripting addition (or osax) is a compiled code fragment, typically written in a language such as C, that extends the AppleScript language (see "Scripting Addition" in Chapter 3). A scripting addition has a dictionary, but it can't be targeted, and doesn't need to be; the commands that it implements are present as if built into AppleScript itself (see Chapter 20).

A scripting addition can define events (commands), records (pseudo-classes), and coercions. Generally speaking, a scripting addition can fulfill two purposes:


Add to AppleScript's powers

AppleScript is a "little language" (see Chapter 4), and in some ways it's just too little. A scripting addition can supplement AppleScript's powers by implementing additional commands.


Define events

A scripting addition's dictionary can provide terminology for an event that some application might send to your script. Using this terminology, you can write an event handler to respond to the event. (See "Event Handlers" in Chapter 9.)

The default Tiger installation includes one scripting addition that adds to AppleScript's powersthe StandardAdditions osax. Many of the commands that it implements are so fundamental that this book treats them as part of the core languagefor example, display dialog, which is used in examples throughout the book, and the very important load script and store script commands (see Chapter 8). (The other installed scripting addition, Digital Hub Scripting, implements no functionality; it defines events, which are discussed in Chapter 26.)

Writing a scripting addition is beyond the scope of this book. If you're interested, Appendix C lists some resources that may prove helpful.

For some tips about speed when accessing a scripting addition command, see "Scripting Additions" in Chapter 22.




AppleScript. The Definitive Guide
AppleScript: The Definitive Guide, 2nd Edition
ISBN: 0596102119
EAN: 2147483647
Year: 2006
Pages: 267
Authors: Matt Neuburg

Similar book on Amazon

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