Chapter 16
408
Expressing constants
A constant is a named value whose content never changes. For example,
TRUE
,
FALSE
,
VOID
, and
EMPTY
are constants because their values are always the same.
The constants
BACKSPACE
,
ENTER
,
QUOTE
,
RETURN
,
SPACE
, and
TAB
refer to keyboard characters.
For example, to test whether the user is pressing the Enter key, use the following statement:
if the key = ENTER then beep
Using operators to manipulate values
Operators are elements that tell Lingo how to combine, compare, or modify the values of an
expression. They include the following:
•
Arithmetic operators (such as
+
,
-
, /, and
*
)
•
Comparison operators (for example,
<>
,
>
, and
>=
), which compare two arguments
•
Logical operators (
not
,
and
,
or
), which combine simple conditions into compound ones
•
String operators (
&
and
&&
), which join strings of characters
Understanding operator precedence
When two or more operators are used in the same statement, some operators take precedence over
others in a precise hierarchy that Lingo follows to determine which operators to execute first. This
is called the operators’ precedence order. For example, multiplication is always performed before
addition. However, items in parentheses take precedence over multiplication. For example,
without parentheses, Lingo performs the multiplication in this statement first:
total = 2 + 4 * 3
The result is 14.
When parentheses surround the addition operation, Lingo performs the addition first:
total = (2 + 4) * 3
The result is 18.
Descriptions of the operators and their precedence order follow. Operators with higher
precedence are performed first. For example, an operator whose precedence order is 5 is
performed before an operator whose precedence order is 4. Operations that have the same order
of precedence are performed left to right.
Arithmetic operators
Arithmetic operators add, subtract, multiply, divide, and perform other arithmetic operations.
Parentheses and the minus sign are arithmetic operators.
Operator
Effect
Precedence
( )
Groups operations to control precedence order.
5
-
When placed before a number, reverses the sign of a number. 5
*
Performs multiplication.
4
mod
Performs modulo operation.
4
/
Performs division.
4
Содержание Director MX
Страница 1: ...Using Director MX Macromedia Director MX ...
Страница 12: ...Contents 12 ...
Страница 156: ...Chapter 4 156 ...
Страница 202: ...Chapter 6 202 ...
Страница 244: ...Chapter 7 244 ...
Страница 292: ...Chapter 10 292 ...
Страница 330: ...Chapter 12 330 ...
Страница 356: ...Chapter 13 356 ...
Страница 372: ...Chapter 14 372 ...
Страница 442: ...Chapter 16 442 ...
Страница 472: ...Chapter 18 472 ...
Страница 520: ...Chapter 19 520 ...
Страница 536: ...Chapter 20 536 ...
Страница 562: ...Chapter 23 562 ...
Страница 566: ...Chapter 24 566 ...
Страница 602: ...Chapter 27 602 ...