
These terms are called raw format or raw codes, because they represent the underlying Apple event codes that AppleScript uses to represent scripting terms.įor compatibility with Asian national encodings, “《” and “》” are allowed as synonyms for “«” and “»” ( (Option- \ and Option-Shift- \, respectively, on a U.S. When you open, compile, edit, or run scripts with a script editor, you may occasionally see terms enclosed in double angle brackets, or chevrons («»), in a script window or in another window. AppleScript stores the result in the globally available property result, described in AppleScript Constant. The result of the statement set myText to "keyboard" is the text object "keyboard". For example, executing the statement 3 + 4 results in the value 7. The result of a statement is the value generated, if any, when the statement is executed. Get name of front window of application "Finder"įor more information on command types, parameters, and targets, see Commands Overview.

For example, when the following simple expression is evaluated, the result is 21: When you run a script, AppleScript converts its expressions into values. More complex expressions typically combine literals, variables, operators, and object specifiers. The simplest kinds of expressions, called literal expressions, are representations of values in scripts. Expressions are used in scripts to represent or derive values.

#APPLESCRIPT CLEAN TEXT SERIES#
ExpressionsĪn expression is any series of lexical elements that has a value. For example, you can assign the integer value 17 to a variable, then later assign the Boolean value true to the same variable.įor more information, see Variables and Properties. A variable is contained in a script and its value is normally lost when you close the script that contains it.ĪppleScript variables can hold values of any class. When AppleScript encounters a variable, it evaluates the variable by getting its value. Statements that assign values to variables are known as assignment statements. As depicted in a script, a list consists of a series of expressions contained within braces and separated by commas, such as the following: ListĪ list defines an ordered collection of values, known as items, of any class. For related information, see the constant class. Global Constants in AppleScript describes constants that can be used throughout your scripts. BooleanĪppleScript defines the Boolean values true and false and supplies the boolean class. For example, AppleScript defines a number of enumerated constants for use with the path to (folder) command, each of which specifies a location for which to obtain the path. A constant is a word with a predefined value. In AppleScript, for example, "Hello" is a text literal.

Literals and ConstantsĪ literal is a value that evaluates to itself-that is, it is interpreted just as it is written. That means they can be placed on the same line at the beginning or end of a statement, but cannot be embedded within a simple (one-line) statement.Īn end-of-line comment begins with the characters - (two hyphens) and ends with the end of the line:ĭisplay dialog "This is just a test." buttons ¬Ī continuation character within a quoted text string is treated like any other character. Block comments must be placed between other statements. There are three kinds of comments:Ī block comment begins with the characters (* and ends with the characters *). You can use comments to describe what is happening in the script or make other kinds of notes. Table 1-1 AppleScript reserved words, listed alphabeticallyĪ comment is text that is ignored by AppleScript when a script is executed.

IdentifiersĪn AppleScript identifier is a series of characters that identifies a class name, variable, or other language element, such as labels for properties and handlers.Īn identifier must begin with a letter and can contain any of these characters: For information on characters that AppleScript treats specially, see the sections Identifiers, Comments, Text, The Continuation Character, and Raw Codes in this chapter, as well as Table 9-1 in Operators Reference. AppleScript preserves all characters correctly worldwide, and comments and text constants in scripts may contain any Unicode characters.ĪppleScript syntax uses several non-ASCII characters, which can be typed using special key combinations. Starting in OS X v10.5 (AppleScript 2.0), the character set for AppleScript is Unicode. It starts with the character set and introduces elements of increasing complexity.Īfter reading this chapter, you should have an understanding of the basic language components used to construct AppleScript expressions and statements.ĪppleScript Lexical Conventions contains the following sections: This chapter provides an overview of the vocabulary and conventions of the AppleScript Language. Next Previous AppleScript Lexical Conventions
