26
Chapter 2: Director Scripting Essentials
Arithmetic operators
Arithmetic operators add, subtract, multiply, divide, and perform other arithmetic operations.
Parentheses and the minus sign are also arithmetic operators.
Note:
In Lingo, when only integers are used in an operation, the result is an integer. Using integers
and floating-point numbers in the same calculation results in a floating-point number. In JavaScript
syntax, all calculations essentially result in floating-point numbers.
When dividing one integer by another does not result in a whole number, Lingo rounds the result
down to the nearest integer. For example, the result of
4/3
is
1
. In JavaScript syntax, the actual
floating-point value, 1.333, is returned.
To force Lingo to calculate a value without rounding the result, use
float()
on one or more
values in an expression. For example, the result of
4/float(3)
is 1.333.
Comparison operators
Comparison operators compare two values and determine whether the comparison is true or false.
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
(Lingo only) Performs modulo operation.
4
/
Performs division.
4
%
(JavaScript syntax only) Returns the integer remainder of dividing
two operands.
4
++
(JavaScript syntax only) Adds one to its operand. If used as a prefix
operator (
++x
), returns the value of its operand after adding one. If used
as a postfix operator (
x++
), returns the value of its operand before
adding one.
4
--
(JavaScript syntax only) Subtracts one from its operand. The return
value is analogous to that of the increment operator.
4
+
When placed between two numbers, performs addition.
3
-
When placed between two numbers, performs subtraction.
3
Operator
Meaning
Precedence
==
(JavaScript syntax only) Two operands are equal. If the operands are
not of the same data type, JavaScript syntax attempts to convert the
operands to an appropriate data type for the comparison.
1
===
(JavaScript syntax only) Two operands are equal and of the same
data type
1
!=
(JavaScript syntax only) Two operands are not equal. If the operands
are not of the same data type, JavaScript syntax attempts to convert the
operands to an appropriate data type for the comparison.
1
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...