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 ...
Get Lingo in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.