List component can be used to hold items of any type.
Creating a List:
From scripting you can create a variable of the type
List by the following code:
var list = new TList();
Example:
var list = new
TList();
list.
Add("element");
list.
Add(3);
The list constructed in the above code will contain a string in the first position and an integer in the second.
Functions:
Properties:
function Item(Index)
Use Item to obtain a specific item from the list. Use Item with the Count property to iterate through all of the items in the list.
Parameter list:
- Index
The Index parameter indicates the integer index of the item, where 0 is the index of the first item, 1 is the index of the second item, and so on
Return values:
Returns the item from the given index.
function Add(Item)
Call Add to insert a new item at the end of the list.
Parameter list:
- Item
The item that needs to be inserted. Can be of any type.
function Remove(Index)
Call Remove to delete the item from the given index. Calling Remove moves up all items in the list that follow the deleted item, and reduces the Count.
Parameter list:
- Index
The Index parameter indicates the integer index of the item which needs to be removed
function Insert(Index, Item)
Call Insert to add item to the middle of the list. Insert adds the item at the indicated position, shifting the item that previously occupied that position, and all subsequent items, up. Insert increments Count.
Parameter list:
- Index
The Index parameter indicates the integer index where the item should be inserted
- Item
The item that needs to be inserted. Can be of any type.
function Move(Index1, Index2)
Call this function to move the item at the position Index1 so that it occupies the position Index2.
Parameter list:
- Index1
Integer index from the list
- Index2
Integer index from the list
function Clear()
Empty the list and set the Count to 0.
function IndexOf(Item)
Gets the index for an item in the list.
Parameter list:
- Item
The item to look for. Can be of any type.
Return values:
Returns the index if the item is in the list or -1 if it's not found.
property Count
Read only integer property with the number of elements in the list.