|
Property lists
This article assumes that the reader is already familiar with basic Lingo. This article is not for beginning Lingo programmers.
As described in Why and how to use linear lists, linear lists store values in variables. Even more exotic than linear lists are property lists. What the heck are property lists?
Property lists are like collections of information with name tags on them. Each item is labeled with a descriptive name. The name is the "property." The item itself is the "value" that property has.
The terminology derives from the concept that a list is a set of related information, which consists of properties and their associated values. For instance, let's say the list describes your car. It might look like this (in concept):
Make:Toyota
Model: Corolla
Style: Liftback
Year:1986
Color: Blue
A property list can easily encapsulate this information. To make the list explicit, you would do this:
set myCar =[#make:"Toyota", #model:"Corolla",
#style:"Liftback", #year:1986, #color:"Blue"]
From this, you can start to see some of the attributes of a property list. To begin with, each property:value pair takes the form property:value; that is, two items separated by a colon. Each property:value pair represents a list entry. For instance, [#english:"Hello", #french:"Bonjour", #spanish:"Hola"] has three entries. The car example prior to that has five entries.
In this example, you used symbols as the properties. Symbols are the most common choice for properties, but they're by no means the only choice. To my knowledge, you can use almost anything, even other lists; but symbols are the most common. Numbers are useful too, as you'll see later on.
- Getting Values by Property
- List functions
- Changing Values
- List Iteration
- Finding indexes
|