List

The List Data Type is used to group together Values in a specific order. These Values can be strings of text, numbers, or any other data type. It can also contain other Lists.

Structure

The syntax for creating a List is to enclose a set of Values inside square brackets, separating them with commas - like Arrays in other languages.

A specific type of List can be preselected, like List of Text, or a generic type of List can be created if it will include a combination of Values.

Examples

To create a List with the numbers 1, 2, and 3 write the following Airscript Expression:

[ 1, 2, 3 ]

Once grouped, the Values can be accessed by their numeric index. The indices begin at zero, so the first value is located at index 0.

Assuming the List above is stored in a my_list Variable, we would write the following Airscript Expression to access the first Value:

my_list[0] -> 1

Any Expression that results in a Number can be used. Perhaps there is an offset Variable that holds a number that is meant to index my_list. In order to retrieve the value at that index, we would write the following Airscript:

my_list[offset]

If the provided index is greater than, or equal to, the length of the list, the result will be NULL. Using my_list the following Expression will result in NULL:

my_list[3] -> NULL

Lists can contain a series of objects:

[
  { "name": "John", "number": "1" },
  { "name": "Scott", "number": "2" },
  { "name": "Michael", "number": "3" }
]

In Airscript, there are no direct equivalent .push or .append methods available. To achieve the same result, use the function FLAT to append some new item (new_item) to an established list (my_list):

FLAT([my_list, new_item])