Lists of variables are created in the structure tree of a TCE class, in which the <List> switch is activated in the properties of a variable.
Local variables are declared as a list in which an opening and closing bracket “()” is appended to the name of the variable.
Dim Cars() As ::Car, DoubleList() As Double, VariantList() As Variant
Example of a list declaration for a TCE object pointer or local object list.
Lists of variables have a zero-based index. The first element of a list can therefore be addressed via:
S := Cars(0)
Lists of variables do not need to be redimensioned. By assigning an index, TCE does this automatically.
Dim Cars() As "Car"
Cars(2) := "BMW"
Cars(5) := "Mercedes"
Lists can also be enclosed with curly braces using the short notation:
Cars := {”Mercedes”, NoValue, ”BMW”}
In this spelling, in variable Cars(0) an object of the class "Mercedes" will be created, Cars(1) remains NoValue and in Cars(2) an object of the class "BMW" will be created.
In order to better understand that these are newly created objects of a certain class, the following spelling is also available:
Cars := {New ::Mercedes, NoValue, New ::BMW}
The lower and upper bounds of a list can be determined using the LowBound and UpBound attributes. If a list is empty, Upbound returns -1, otherwise the highest index will be returned. LowBound returns -1 for empty lists, otherwise the smallest occupied index.
A list is run correctly when the following code is executed:
Dim i As Long
If Cars.UpBound > -1 Then
For i := Cars.LowBound To Cars.UpBound
If Cars(i) <> NoValue Then
S := Cars(i).Modelname
End If
EndFor
End If
If the index is not interesting for programming, a simplified code can be executed:
Dim A As ::Car, s As String
For Each A In Cars
s := A.Modelname
EndFor
Lists of variables, like all other TCE variable Types have attributes and attribute functions:
Variant lists allow the creation of heterogeneous arrays.
Dim Array() As Variant, Value As String
Array := {{"A", 1, 10}, {"B", 2, 20}, {"C", 3, 30}}
Value := Array(1)(0)
Value accordingly contains the value 'B'.
Standard attributes and attribute functions:
GetStringList (Listen-Variable)
RemoveLast (Lists of variables)