String
A string is the basic text datatype. It has the MacRoman encoding; see "Unicode Text," later in this chapter, for more about the implications of this. Strings are your primary medium for communicating text information to a scriptable application. AppleScript provides some basic string operators (discussed in Chapter 15).
A literal string is delimited by quotation marks:
set s to "howdy"
class of s -- stringThe empty
string
is symbolized by "".
In typing a string literal, you may enter certain characters in "escaped " form; they are listed in Table 13-1. These are the only "escaped" characters.
Table 13-1. "Escaped" string literals
|
What to type |
ASCII equivalent |
Result |
|---|---|---|
|
|
ASCII character 34 |
Quotation marks |
|
|
ASCII character 9 |
Tab |
|
|
ASCII character 13 |
Return |
|
|
ASCII character 10 |
Newline |
|
|
ASCII character 92 |
Backslash |
Other untypeable characters may be generated using the ASCII character scripting addition command and incorporated into a string by concatenation (see chapters 15 and 21). There are also a few global properties expressing character values (listed in Chapter 16); these too can be incorporated into a string by concatenation.
After compilation, any tab, return, and newline characters within a literal string are unescaped and turned into whitespace ; they remain intact, but you can no longer see directly what characters they are, which is a pity (see "Lines" in Chapter 5). Script Debugger, however, can display such "invisibles."
Don't ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access