Chapter 16
410
String operators
String operators combine and define strings. These are the string operators available in Lingo:
Controlling flow in scripts
Lingo uses
if...then...else
,
case
, and
repeat
statements to perform an action depending on
whether a condition exists. See the following sections.
Using if statements
Statements that check whether a condition is true or false begin with the Lingo term
if.
If the
condition exists, Lingo executes the statement that follows
then
. If the condition doesn’t exist,
Lingo skips to the next statement in the handler.
To optimize your script’s performance, test for the most likely conditions first.
The following statements test several conditions. The term
else if
specifies alternative tests to
perform if previous conditions are false:
if the mouseMember = memberNum("map 1") then
go to "Cairo"
else if the mouseMember = member ("map 2") then
go to "Nairobi"
else
alert "You’re lost."
end if
When writing
if…then
structures, you can place the statement following
then
in the same line as
then
, or you can place it on its own line by inserting a carriage return after
then
. If you insert a
carriage return, you must also include an
end if
statement at the end of the
if…then
structure.
For example, the following statements are equivalent:
if the mouseMember = member("map 1") then go to "Cairo"
if the mouseMember = member("map 1") then
go to "Cairo"
end if
For more information, see
if
in the Lingo Dictionary.
Using case statements
The
case
statement is a shorthand alternative to repeating
if…then
statements when setting up a
multiple branching structure. A
case
statement is often more efficient and easier to read than a
large number of
if...then...else
statements.
The condition to test for follows the term
case
in the first line of the
case
structure. The
comparison goes through each line in order until Lingo encounters an expression that matches
the test condition. When a matching expression is found, Director executes the Lingo that follows
the matching expression.
Operator
Effect
Precedence
&
Concatenates two strings.
2
&&
Concatenates two strings and inserts a space between the
two.
2
"
Marks the beginning or end of a string.
1
Содержание 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 ...