13.7. Scripting Additions

When you learned how to examine the Standard Additions dictionary in Chapter 4, I briefly mentioned the term osax, which stands for Open Scripting Architecture extension. The Standard Additions osax is stored on your system in the folder /System/Library/ScriptingAdditions under the file name StandardAdditions.osax. Because the Standard Additions is available on all Mac OS X systems, the commands in this text have been treated as an integral part of the AppleScript language. A scripting addition can be written by anyone. After an addition is installed in your ScriptingAdditions folder, the addition's commands and terms become immediately available for use in your AppleScript programs, as if they were built into the language.

Satimage is a company that offers several scripting additions. These include a math addition that provides arithmetic and transcendental functions; a text addition for performing search and replace operations and formatting numbers; a files addition that enhances some of the Standard Additions commands; and a regular expressions addition for working with regular expressions.

As an example, the Satimage osax contains a command called change that performs a search and replace on a character string. By placing that osax file into the ScriptingAdditions folder, I can write a command like this directly in my program:

change " " into "X" in "This is a test of the Emergency Broadcast System"

This changes all occurrences of a space character ...

Get Beginning AppleScript® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.