O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Lists

List Basics

There are two major types of Lingo lists—linear lists and property lists. Refer to Chapter 5, Coordinates, Alignment, and Registration Points, in Director in a Nutshell for an additional details on rects and points, which are list-style structures sharing characteristics of both linear and property lists.

Lists (called arrays in most languages) are convenient for storing and retrieving related data. A list consists of zero or more elements, which can be of any data type, enclosed in square brackets. Elements are separated by commas.

Tip

Simplify global variable management by using a single global list with multiple properties instead of individual global variables.

You do not need to allocate a specific amount of memory or number of elements for a list. Director handles the housekeeping as elements are added or deleted. Elements are often referred to by their index (that is, their position in the list).

Tip

The index of the first element’s in a list is 1, not 0 as in some other languages. Do not use 0 or negative numbers as indices.

Linear Lists

A linear list is a simple comma-delimited list of elements, defined using the list() function or by enclosing items within square brackets. Each element can be of any data type. Use list() without any elements, or empty brackets, [ ], to create a zero-element linear list. Here are some example linear lists:

set emptyList = [ ]
set myList1 = [1, 2, 3]
set myList2 = list (1, 7, #fumble, "Apples", 6.5, "Money")

Don’t include ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required