326
Chapter 12: Methods
getAt
Usage
getAt(
list
,
position
)
list
[
position
]
Description
List command; identifies the item in a specified position of a specified list. If the list contains
fewer elements than the specified position, a script error occurs.
The
getAt
command works with linear and property lists. This command has the same function
as the
getaProp
command for linear lists.
This command is useful for extracting a list from within another list, such as the
deskTopRectList.
Parameters
list
Required. Specifies the list from in which the item exists.
position
Required. Specifies the index position of the item in the list.
Example
This statement causes the Message window to display the third item in the answers list, which
consists of [10, 12, 15, 22]:
put getAt(answers, 3)
-- 15
The same result can be returned using bracket access:
put answers[3]
-- 15
The following example extracts the first entry in a list containing two entries that specify name,
department, and employee number information. Then the second element of the newly extracted
list is returned, identifying the department in which the first person in the list is employed. The
format of the list is [[“Dennis”, “consulting”, 510], [“Sherry”, “Distribution”, 973]], and the list is
called employeeInfoList.
firstPerson = getAt(employeeInfoList, 1)
put firstPerson
-- ["Dennis", "consulting", 510]
firstPersonDept = getAt(firstPerson, 2)
put firstPersonDept
-- "consulting"
It’s also possible to nest
getAt
commands without assigning values to variables in intermediate
steps. This format can be more difficult to read and write, but less verbose.
firstPersonDept = getAt(getAt(employeeInfoList, 1), 2)
put firstPersonDept
-- "consulting"
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...