User Guide

Writing Scripts with Lingo 401
Adding and deleting items in a list
You can add or delete items in a list by using the following commands. See entries for individual
commands in the Lingo Dictionary.
To add an item at the end of a list, use the append command.
To add an item at its proper position in a sorted list, use the add or addProp command.
To add an item at a specific place in a linear list, use the addAt command.
To add an item at a specific position in a property list, use the addProp command.
To delete an item from a list, use the deleteAt, deleteOne, or deleteProp command.
To replace an item in a list, use the setAt or setaProp command.
You do not have to explicitly remove lists. Lists are automatically removed when they are no
longer referred to by any variable. Other types of objects must be removed explicitly, by setting
variables that refer to them to
VOID.
Copying lists
Assigning a list to a variable and then assigning that variable to a second variable does not make a
separate copy of the list. For example, the statement
landList = ["Asia", "Africa"] creates a
list that contains the names of two continents. The statement
continentList = landList
assigns the same list to the variable continentList. However, adding Australia to landList
using the statement add landList, "Australia" automatically adds Australia to
continentList also. This happens because both variable names point to the same object
in memory.
To create a copy of a list that is independent of the first list:
Use the duplicate() function. See duplicate() (list function) in the Lingo Dictionary.
For example, this statement creates a list and assigns it to the variable
oldList:
oldList = ["a", "b", "c"]
This statement uses the duplicate() function to make an independent copy of the list and
assign it to the variable
newList:
newList = duplicate(oldList)
After newList is created, editing either oldList or newList has no effect on the other.
Sorting lists
Lists can be unsorted. However, Lingo can sort a list in alphanumeric order, with numbers before
strings. Strings are sorted according to their initial letters, regardless of how many characters they
contain. Sorted lists perform slightly faster than unsorted lists.
Lingo sorts a linear list according to the values in the list. Lingo sorts a property list according to
the properties in the list.
To sort a list:
Use the sort command followed by the lists name. See sort in the Lingo Dictionary.