Writing Scripts with Lingo
405
Writing strings
Strings are words or groups of characters that Lingo treats as regular words instead of as variables.
Strings must be enclosed in double quotation marks. For example, you might use strings to give
messages to the user of your movie or to name cast members. In the statement
member ("Greeting").text = "Hello"
“Hello” and “Greeting” are both strings. “Hello” is the literal text being put into the text cast
member; “Greeting” is the name of the cast member.
Similarly, if you test a string, double quotation marks must surround each string, as in the
following example:
if "Hello Mr. Jones" contains "Hello" then soundHandler
Lingo treats spaces at the beginning or end of a string as a literal part of the string. The following
expression includes a space after the word to:
put "My thoughts amount to "
Although Lingo does not distinguish between uppercase and lowercase when referring to cast
members, variables, and so on, literal strings are case sensitive. For example, the following two
statements place different text into the specified cast member, because
"Hello"
and
"HELLO"
are
literal strings.
member ("Greeting").text = "Hello"
member ("Greeting").text = "HELLO"
Using integers
An integer is a whole number, without any fractions or decimal places.
Director works with integers between -2,147,483,648 and +2,147,483,647. (For numbers
outside this range, use decimal numbers, sometimes called floating-point numbers.) Enter
integers without using commas. Use a minus (
-
) sign for negative numbers.
You can convert a decimal number to an integer by using the
integer()
function. For example,
the statement
set theNumber = integer(3.9)
rounds off the decimal number 3.9 and converts
it to the integer 4.
Some Lingo commands and functions require integers for their parameters. The requirements for
specific Lingo elements can be found in Director Help or the Lingo Dictionary.
Using decimal numbers
A decimal number, sometimes called a floating-point number, is any number that includes a
decimal point. The
floatPrecision
property controls the number of decimal places used to
display these numbers. (However, Director always uses the complete number in calculations.) For
information about setting the number of decimal places used for decimal numbers, see the
floatPrecision
entry in Director Help or the Lingo Dictionary.
You can also use exponential notation with decimal numbers: for example, -
1.1234e-100
or
123.4e+9
.
You can convert an integer or string to a decimal number by using the
float()
function. For
example, the statement
set theNumber = float(3)
stores the value
3.0
in the variable.
Содержание DIRECTOR MX-USING 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...