next up previous
Next: Lingo operators Up: Multimedia Programming:Scripting (Lingo) Previous: Literal Values

Identifying cast members and casts

Lingo refers to a cast member by using the term member followed by a cast member name or number in parentheses. If more than one cast member has the same name, Director uses the lowest numbered cast member in the lowest numbered cast. (Cast member names are strings and follow the same syntax rules as other strings.) An alternative syntax is the term member without parentheses, followed by the cast member name or number.

For example, the following all refer to cast member 50, which has the name Jason_Jones-Hughes:

member("Jason_Jones-Hughes")
member(50) 
member "Jason_Jones-Hughes" 
member 50

Use an optional second parameter to specify the cast member's cast. If more than one cast contains a cast member with the same name, you must also specify the cast. If you identify a cast member by its cast member number, you must also specify the cast. To specify a cast when using member without parentheses, include the term of castLib followed by the cast's name or number.

When the cast member's name is unique in the movie, the cast's name isn't required, but you can include it for clarity. For example, the following statements refer to cast member 50, which is named Jason_Jones-Hughes, in castLib 4, which is named Wales_Player:

member(50, 4) 
member 50 of castLib 4 
member("Jason_Jones-Hughes", 4) 
member "Jason_Jones-Hughes" of castLib 4 
member(50, "Wales_Player")
member 50 of castLib "Wales_Player"
member("Jason_Jones-Hughes", "Wales_Player")
member "Jason_Jones-Hughes" of castLib "Wales_Player"

If more than one cast member has the same name and you use the name in a script without specifying the cast or cast member number, Lingo uses the first (lowest numbered) cast member in the lowest numbered cast that has the specified name.

A symbol is a string or other value that begins with the pound sign (#). Symbols are user-defined constants. Comparisons using symbols can usually be performed very quickly, providing more efficient code. For example, the statement

userLevel = #novice

runs more quickly than the statement

userLevel = "novice"

Symbols can't contain spaces or punctuation. Convert a string to a symbol by using the symbol() function. Convert a symbol back to a string by using the string() function.

A constant is a named value whose content never changes. For example, TRUE, VOID, and EMPTY are constants because their values are always the same. The constants BACKSPACE, ENTER, QUOTE, RETURN, SPACE, and TAB refer to keyboard characters. For example, to test whether the user is pressing the Enter key, use the following statement:

if the key = ENTER then beep


next up previous
Next: Lingo operators Up: Multimedia Programming:Scripting (Lingo) Previous: Literal Values
Dave Marshall
10/4/2001