Language Guide
CHAPTER 3
Values
70 Coercing Values
Figure 3-2 Coercions supported by AppleScript
Three of the identifiers mentioned at the top of Figure 3-2 act only as synonyms
for other value classes: “number” is a synonym for either “integer” or “real,”
“text” is a synonym for “string,” and “styled text” is a synonym for a string
that contains style and font information. You can coerce values using these
synonyms, but the class of the resulting value is always the appropriate value
class, not the synonym. Here are some examples:
set x to 1.5 as number
class of x
--result: real
Boolean
Class
Constant
Integer
Single-item list
Multi-item list
Number
Record
String or text
Styled text*
Coerce to
Coerce from
Boolean
Class
Constant
Data
Date
Integer
Single-item list
Multi-item list
Real
Record
String
Data
Date
Real
†
‡
* Only values that include style and font information can be coerced to styled text.
† Only a list whose items can all be coerced to strings can be coerced to a string.
‡ Only a real value that has no fractional part can be coerced to an integer.