EasyManua.ls Logo

MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING - Page 42

MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING
1130 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
42 Chapter 2: Director Scripting Essentials
Checking items in lists
You can determine the characteristics of a list and the number of items the list contains by
using the following methods.
To display the contents of a list, use the put() or trace() functions, passing the variable that
contains the list as a parameter.
To determine the number of items in a list, use the count() method (Lingo only) or the
count property.
To determine a list’s type, use the ilk() method.
To determine the maximum value in a list, use the max() method.
To determine the minimum value in a list, use the min() function.
To determine the position of a specific property, use the findPos, findPosNear, or
getOne command.
The following statements use
count() and count to display the number of items in a list.
-- Lingo syntax
workerList = ["Bruno", "Heather", "Carlos"] -- define a linear list
trace(workerList.count()) -- displays 3
trace(workerList.count) -- displays 3
// JavaScript syntax
var workerList = list("Bruno", "Heather", "Carlos"); // define a linear list
trace(workerList.count); // displays 3
The following statements use ilk() to determine a lists type.
-- Lingo syntax
x = ["1", "2", "3"]
trace(x.ilk()) // returns #list
// JavaScript syntax
var x = list("1", "2", "3");
trace(x.ilk()) // returns #list
The following statements use max() and min() to determine the maximum and minimum values
in a list.
-- Lingo syntax
workerList = ["Bruno", "Heather", "Carlos"] -- define a linear list
trace(workerList.max()) -- displays "Heather"
trace(workerList.min()) -- displays "Bruno"
// JavaScript syntax
var workerList = list("Bruno", "Heather", "Carlos"); // define a linear list
trace(workerList.max()); // displays Heather
trace(workerList.min()); // displays Bruno
The following statements use findPos to get the index position of a specified property in a
property list.
-- Lingo syntax
-- define a property list
foodList = [#breakfast:"Waffles", #lunch:"Tofu Burger"]
trace(foodList.findPos(#lunch)) -- displays 2
// JavaScript syntax
// define a property list
var foodList = propList("breakfast", "Waffles", "lunch", "Tofu Burger");
trace(foodList.findPos("breakfast")); // displays 1

Related product manuals