Language Guide

CHAPTER 3
Values
Using Value Class Denitions 37
Literal Expressions 3
A literal expression is an expression that evaluates to itself. The “Literal
Expressions” section of a value class definition shows examples of how values
of a particular class are represented in AppleScript—that is, typical literal
expressions for values of that class. For example, in AppleScript and many
other programming languages, the literal expression for a string is a series of
characters enclosed in quotation marks. The quotation marks are not part of the
string value; they are a notation that indicates where the string begins and
ends. The actual string value is a data structure stored in AppleScript.
The sample value class definition in Figure 3-1 shows literal expressions for list
values. As with the quotation marks in a string literal expression, the braces
that enclose a list and the commas that separate its items are not part of the
actual list value; they are notations that represent the grouping and items of
the list.
Properties 3
A property of a value is a characteristic that is identified by a unique label and
has a single value. Simple values have only one property, called Class, that
identifies the class of the value. Composite values have a Class property, a
Length property, and in some cases additional properties.
Use the Name reference form to specify properties of values. For example, the
following reference specifies the Class property of an integer.
class of 101
--result: integer
The following reference specifies the Length property of a list.
length of {"This", "list", "has", 5, "items"}
--result: 5
You can optionally use the Get command with the Name reference form to
get the value of a property for a specified value. In most cases, you can also
use the Set command to set the additional properties listed in the definitions
of composite values. If a property cannot be set with the Set command, its
definition specifies that it is read-only.