AppleScript Programming/Lists and records

For the best results, you should have Script Editor open, so you can test the code and results as you read.

Basics of Lists
Applescript has two separate classes of data structure that are used to represent a collection of items: the   class, and the   class. A list is an ordered collection of objects, which can be any value or data structure that AppleScript understands. To say that the contents of a list is ordered means that every item in the list occupies a numbered position. This number is termed the item's index, which can be used to retrieve a specific item from a list.

List creation is simple, anything that you put between a  and a   is a list.

In the example above we create two lists. The first list  contains 5 items, the number 1, a string "two", a list containing the number 7, a record containing three properties, fred, wilma, and foo with string values, and the number 5.

We can access these items in several ways. The statements

Will all return the same value,, that is, a list containing the number 7.

Looping Through a String As If It Were a List
This works a character at a time. (Strings are sequences of characters and behave accordingly.)

Basics of Records
A record is a list of properties. You can retrieve items from a record by name, but not by index. For example, to retrieve the  of the property list , I can retrieve it by name.

Which will return the string

but not by index,

Which returns an error.