600
Chapter 13: Operators
This statement concatenates the strings “Today is” and today’s date in the long format and inserts
a space between the two:
-- Lingo syntax
put("Today is" && date())
// JavaScript syntax
put("Today is " + Date());
() (parentheses)
Usage
-- Lingo syntax
(
expression
)
// JavaScript syntax
(
expression
)
Description
Grouping operator; performs a grouping operation on an expression to control the order of
execution of the operators in an expression. This operator overrides the automatic precedence
order so that the expression within the parentheses is evaluated first. When parentheses are nested,
the contents of the inner parentheses are evaluated before the contents of the outer ones.
This is a grouping operator with a precedence level of 5.
Be aware that Lingo allows you to use some commands and functions that take only one
argument without parentheses surrounding the argument. When an argument phrase includes
an operator, Lingo interprets only the first argument as part of the function, which may
confuse Lingo.
For example, the
open window
command allows one argument that specifies which window to
open. If you use the
&
operator to define a pathname and filename, Director interprets only the
string before the
&
operator as the filename. For example, Lingo interprets the statement
open
window the applicationPath & "theMovie"
as
(open window the applicationPath) &
("theMovie")
. Avoid this problem by placing parentheses around the entire phrase that includes
an operator, as follows:
-- Lingo syntax
open window (the applicationPath & "theMovie")
// JavaScript syntax
window(the applicati "theMovie").open();
Example
These statements use the grouping operator to change the order in which operations occur (the
result appears below each statement):
-- Lingo syntax
put((2 + 3) * (4 + 5))
-- 45
put(2 + (3 * (4 + 5)))
-- 29
put(2 + 3 * 4 + 5)
-- 19
Summary of Contents for DIRECTOR MX 2004
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...