Data types

A data type is a set of data with values that have similar, predefined characteristics. Every variable and property value in Director is of a specific data type, and values returned by methods are of a specific data type.

For example, consider the following two statements. In the first statement, variable intX is assigned a whole number value of 14, which is an integer. So, the data type of variable intX is Integer. In the second statement, variable stringX is assigned a sequence of character values, which is a string. So, the data type of variable stringX is String.

-- Lingo syntax 
intX = 14 
stringX = "News Headlines" 
 
// JavaScript syntax 
var intX = 14; 
var stringX = "News Headlines";

The values that are returned by methods or functions are also of an inherent data type. For example, the Player object’s windowPresent() method returns a value that specifies whether a window is present. The returned value is TRUE (1) or FALSE (0).

Some data types are shared between Lingo and JavaScript syntax, and some data types are specific to one language or another. The set of data types that Director supports is fixed and cannot be modified, meaning that new data types cannot be added and existing data types cannot be removed. Director supports the following data types.

Data type

Description

# (symbol)

A self-contained unit that can be used to represent a condition or flag. For example, #list or #word.

Array

(JavaScript syntax only) Although not literally a data type, an Array object can be used to work with linear lists of values. The functionality of an Array object is similar to that of the List data type in Lingo.

Boolean

A value that is TRUE (1) or FALSE (0). In Lingo, all TRUE or FALSE values are simple integer constants, 1 for TRUE, 0 for FALSE. In JavaScript syntax, all true or false values are by default the actual Boolean true or false values, but are converted to simple integer constants automatically when required in Director.

In Lingo, TRUE and FALSE can be either lowercase or uppercase. In JavaScript syntax, true and false must always be lowercase.

Color

Represents an object’s color.

Constant

A piece of data whose value does not change.

Date

Although not literally a data type, in JavaScript syntax a Date object can be used to work with dates. In Lingo, use the date() method to create a Date object and work with dates.

Float

(Lingo only) A floating-point number. For example, 2.345 or 45.43.

Function

(JavaScript syntax only) Although not literally a data type, a Function object can be used to specify a string of code to run.

Integer

(Lingo only) A whole number. For example, 5 or 298.

List

A linear or property list made up of values or property names and values, respectively.

Math

(JavaScript syntax only) Although not literally a data type, a Math object can be used to perform mathematical functions.

null

(JavaScript syntax only) Denotes a variable whose value behaves as 0 in numeric contexts and as false in Boolean contexts.

Number

(JavaScript syntax only) Although not literally a data type, a Number object can be used to represent numerical constants, such as a maximum value, not-a-number (NaN), and infinity.

Object

Although not literally a data type, an Object object can be used to create a custom named container that contains data and methods that act on that data.

Point

A point in the coordinate space that has both a horizontal and vertical coordinate.

Rect

A rectangle in the coordinate space.

RegExp

(JavaScript only) A regular expression pattern that is used to match character combinations in strings.

String

A contiguous sequence of keyboard symbols or character values. For example, "Director" or "$5.00".

undefined

(JavaScript syntax only) Denotes a variable that does not have a value.

Vector

A point in 3D space.

VOID

(Lingo only) Denotes an empty value.

Note: Many of the data types and objects that are specific to JavaScript syntax contain their own set of methods and properties that can be used to further manipulate those types. While the Director Scripting Reference may refer to some of these methods and properties, it does not include complete reference information about them. For more detailed information on these data types and objects, and their methods and properties, see one of the many third-party resources on the subject.

The built-in properties in Director, such as the Cast object’s name property, can only be assigned values that are the same data type as that of the property’s inherent data type. For example, the Cast object’s name property’s inherent data type is a string, so the value must be a string such as News Headlines. If you try to assign a value of a different data type to this property, such as the integer 20, a script error occurs.

If you create your own custom properties, their values can be of any data type, regardless of the data type of the initial value.

Both Lingo and JavaScript syntax are dynamically typed. This means that you do not have to specify the data type of a variable when you declare it, and data types are automatically converted as needed while a script runs.

For example, the following JavaScript syntax initially sets the variable myMovie to an integer, and later in the script it is set to a string. When the script runs, the date type of myMovie is converted automatically:

-- Lingo syntax 
myMovie = 15 -- myMovie is initially set to an integer 
... 
myMovie = "Animations" -- myMovie is later set to a string 
 
// JavaScript syntax 
var myMovie = 15; // myMovie is initially set to an integer 
... 
myMovie = "Animations"; // myMovie is later set to a string