I've got a list defined in Starter Service Process_Globals (and yes it is initialized)
This list is filled with items of a type:
I've made a copy of the arZendingen list to another list -> arZnd
Now I want to add the Zendingregels of all items from arZnd to the first item of arZnd.
The code below doesn't fail, it works however at the "<--MARK" -line happens something strange. Yes tRegel is added to tZend2.Zendingregels. But at the same moment the same item in com.arZendingen is updated also.
Am I missing something? Any thoughts?
B4X:
Sub Process_Globals
Public arZendingen As List
This list is filled with items of a type:
B4X:
Type TZending (zendingid As String, _
vrachtnr As String, _
Zendingregels As List)
I've made a copy of the arZendingen list to another list -> arZnd
Now I want to add the Zendingregels of all items from arZnd to the first item of arZnd.
The code below doesn't fail, it works however at the "<--MARK" -line happens something strange. Yes tRegel is added to tZend2.Zendingregels. But at the same moment the same item in com.arZendingen is updated also.
B4X:
Dim tZend As TZending : tZend.initialize
Dim tSort As TZending : tSort.initialize
iSize = arZnd.Size-1
Dim y As Int
For i = 0 To iSize
If i>iSize Then Exit
If i=0 Then
Dim tZend As TZending : tZend.Initialize
tZend=arZnd.Get(i)
y=i
Else
Dim tSort2 As TZending : tSort2.Initialize
tSort2=arZnd.Get(i)
If tSort2.customer<>tZend.customerThen
Dim tZend As TZending : tZend.Initialize
tZend=tSort
y=1
Else
For j = 0 To tSort2.Zendingregels.Size-1
Dim tRegel As TRegel : tRegel.initialize
tRegel=tSort2.Zendingregels.Get(j)
tZend.Zendingregels.Add(tRegel) '<--MARK
Next
arZnd.RemoveAt(i)
arZnd.RemoveAt(y)
arZnd.InsertAt(y,tZend)
i=i-1
iSize=iSize-1
End If
End If
Next
Am I missing something? Any thoughts?
Last edited: