Constants
A constant is a named value whose content never changes.
In Lingo, the predefined terms
are always the same. The predefined terms
are constants that refer to keyboard characters. For example, to test whether the last key pressed
was the Space bar, use the following statement:
-- Lingo syntax
if _key.keyPressed() = SPACE then beep()
In JavaScript syntax, you can access predefined constants using some of the data types that are
unique to JavaScript syntax. For example, the Number object contains constants such as
Number.MAX_VALUE
, and so on.
Math.E
Note: This reference does not provide in-depth information about the predefined constants in
JavaScript syntax. For more information on these constants, see one of the many third-party
resources on the subject.
In JavaScript syntax, you can also define your own custom constants by using the
For example, the following statement creates a constant named
This value cannot be changed after it has been created.
// JavaScript syntax
const items = 20;
For more information on constants, see
Symbols
A symbol is a string or other value in Lingo that begins with the pound (
Symbols are user-defined constants. Comparisons using symbols can usually be performed very
quickly, providing more efficient code.
For example, the first statement below runs more quickly than the second statement:
-- Lingo syntax
userLevel = #novice
userLevel = "novice"
Symbols cannot contain spaces or punctuation.
In both Lingo and JavaScript syntax, convert a string to a symbol by using the
-- Lingo syntax
x = symbol("novice") -- results in #novice
// JavaScript syntax
var x = symbol("novice"); // results in #novice
Convert a symbol back to a string by using the
method (JavaScript syntax).
-- Lingo syntax
x = string(#novice) -- results in "novice"
// JavaScript syntax
var x = symbol("novice").toString(); // results in "novice"
20
Chapter 2: Director Scripting Essentials
,
TRUE
FALSE
and
, the Math object contains constants such as
Number.NaN
Chapter 9, "Constants," on page
,
, and
are constants because their values
VOID
EMPTY
,
,
BACKSPACE
ENTER
QUOTE
items
function (Lingo) or the
string()
,
,
, and
RETURN
SPACE
Math.PI
keyword.
const
, and assigns it a value of 20.
151.
) sign.
#
method.
symbol()
toString()
TAB
and
Need help?
Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?
Questions and answers