Language Guide

CHAPTER 4
Commands
Using Parameters 81
Phrases such as before paragraph 10 and word 1 are called relative
references and index references, respectively. These kinds of references specify
locations. For more information about these kinds of references, see “Index” on
page 131 and “Relative” on page 139.
Coercion of Parameters 4
If a parameter doesn’t belong to the right class, it may be possible to coerce it,
that is, to change it into a value of another class. For example, you can coerce
an integer such as 2 to the corresponding string "2" using the As operator:
2 as string
AppleScript performs some coercions, including the previous one, automat-
ically. For example, in the following statement, the direct parameter of the
Copy command should be a string because it is being inserted into a text
editor document.
tell application "Scriptable Text Editor"
copy 12 to beginning of document "Introduction"
end tell
When AppleScript executes this statement, it automatically coerces the integer
12 to the string "12" and inserts the string at the beginning of the document.
The coercions that AppleScript can perform are listed in Chapter 3, “Values.”
Applications can also perform additional coercions, such as coercions for
classes that are specific to an application. These coercions are listed in the
documentation for the application.
Raw Data in Parameters 4
Some application commands return values that do not belong to any of the
normal AppleScript value classes. An example is the Edit Graphic command
supported by some graphics applications. The values that are returned belong
to the class Data, which is described in Chapter 3, “Values.” Values of class
Data cannot be displayed by AppleScript, but they can be stored in variables
and sent as parameters in other commands. For example, if it’s necessary to use