This product version has reached end of life and is no longer supported. Click here for the latest documentation.
A List is a sequence of elements of the same data type, which may contain duplicate values. Elements can be inserted, fetched and removed from a list.
By default a list is empty, meaning that it has no elements. However, you can use the system actions to manipulate an empty list.
To iterate through the elements of a List, use a For Each :
You can't add or remove elements to a list while iterating it. This raises an exception.
If you want to access a specific element of the list with an index,
you can do it using
<List>[<index>]
.
Make sure you use valid values as index, otherwise you'll get a runtime
error. To do so, use List.Empty and List.Length runtime properties.
When a List is created, OutSystems Platform provides you with the following runtime properties:
Property |
Type |
Access type |
Comment |
Current |
List element type |
Read/write. |
Allows direct access to the current element. |
EOF |
Boolean |
Read only. |
Indicates whether the end of the list was exceeded. When you are iterating the last element, this property is still FALSE. |
BOF |
Boolean |
Read only. |
Indicates whether you are at the beginning of the list. When you are iterating the first element, this property is True. |
CurrentRowNumber |
Integer |
Read only. |
The index of the current element in the list, starting with 0. If the list is empty, this property is 0. |
Length |
Integer |
Read only. |
The number of elements currently in the list. |
Empty |
Boolean |
Read only. |
Indicates whether the list is empty. |
The following System Actions are available to manipulate a List:
System Action |
Description |
Adds an element to the end of a list. |
|
Adds the elements of the source list to the end of the destination list. |
|
Removes all elements from the list. |
|
Duplicates the contents of a list into another list. |
|
Inserts an element in a specific position of a list. |
|
Removes an element from a specific position of a list. |
Variables of List data type have a reference to the values, so don't contain a copy of the elements.
You have two lists, one with the customers from Philadelphia, named 'PhiladelphiaCustomers', and other with the customers form New York, named 'NewYorkCustomers'. If you assign the 'PhiladelfiaCustomers' to the 'NewYorkCustomers' list you will have two variables pointing to the same list of customers instead of two independent copies. So when changing values in one variable, the other is also changed.
See Also
Overview of System Actions and Functions | Available Data Types