Identifiers
An identifier is a series of characters that identifies a value or other language element. For example, variable names are identifiers. In the following statement, the variable namemyNameidentifies the value"Fred".
set myName to "Fred"Identifiers are also used as labels for properties and handlers. You'll learn about these uses later in this guide.An identifier must begin with a letter and can contain uppercase letters, lowercase letters, numerals (0-9), and the underscore character (_). Here
are some examples of valid identifiers:
Yes Agent99 Just_Do_ItThe following are not valid identifiers:
C-- Back&Forth 999 Why^NotIdentifiers whose first and last characters are vertical bars (|) can contain any characters. For example, the following are legal identifiers:
|Back and Forth| |Right*Now!|Identifiers whose first and last characters are vertical bars can contain additional vertical bars if the vertical bars are preceded by backslash (\) characters, as in the identifier|This\|Or\|That|. A backslash character in an identifier must be preceded by a backslash character, as in the identifier|/\\ Up \\/ Down|.AppleScript identifiers are not case sensitive. For example, the variable identifiers
myvariableandMyVariableare equivalent.Identifiers cannot be the same as any reserved words--that is, words in the system dictionary or words in the dictionary of the application named in the Tell statement. For example, you cannot create a variable whose identifier is
Yeswithin a Tell statement to the Scriptable Text Editor, becauseYesis a constant from the Scriptable Text Editor dictionary. In this case, AppleScript returns a syntax error if you useYesas a variable identifier.