' Type complexType(number As Int, text As String, colors() As Int, names As List)
Private Sub Button1_Click
Dim aa As complexType = CreateComplexType(123, "ABCDEFG", Array As Int(xui.Color_Black, xui.Color_White), Array("William", "Malcolm"))
Dim bb As complexType = copyComplexType(aa)
bb.names.Set(1, "John")
Log(aa.names.Get(1) & TAB & bb.Names.Get(1))
End Sub
'Note this sub is automatically created when you hover over the Type name in the declaration - but needs to be modified for colors and names
Public Sub CreateComplexType (number As Int, text As String, colors() As Int, names As List) As complexType
Dim t1 As complexType
t1.Initialize
t1.number = number
t1.text = text
t1.colors = copyIntArray(colors)
t1.names = copyList(names)
Return t1
End Sub
Public Sub copyComplexType(ct As complexType) As complexType
Dim resultCt As complexType
resultCt.Initialize
resultCt.number = ct.number
resultCt.text = ct.text
resultCt.colors = copyIntArray(ct.colors)
resultCt.names = copyList(ct.names)
Return resultCt
End Sub
Public Sub copyIntArray(ar() As Int) As Int()
Dim resultAr(ar.length) As Int
For i = 0 To ar.Length - 1
resultAr(i) = ar(i)
Next
Return resultAr
End Sub
Public Sub copyList(aList As List) As List
Dim resultList As List
resultList.Initialize
For i = 0 To aList.Size - 1
resultList.Add(aList.Get(i)) 'if item is non-primitive then a pointer to a shared object is added
Next
Return resultList
End Sub