Bug? Load a List [solved]

luciano deri

Active Member
Licensed User
Longtime User
Hello, in this example there are two ways to load a list that I thought were equivalent, however the first method does not work and I think it is a nice bug.
B4X:
 Sub EsempioLista
    Dim list1 As List
    list1.Initialize
    Dim cols (05) As String
    cols (0) = "A"
    cols (1) = "B"
    cols (2) = "C"
    cols (3) = "D"
    cols (4) = "E"
    list1.Add (cols)
    'From this point by changing the content of cols it changes the content of the first list1 position
    cols (0) = "F"
    cols (1) = "G"
    cols (2) = "H"
    cols (3) = "I"
    cols (4) = "L"
    list1.Add (cols)
    'Here I find list1 (1) and list1 (2) equal
end Sub
sub EsempioLista2
    Dim list1 As List
    list1.Initialize
    Dim cols (05) As String
    cols = Array As String ( "A", "B", "C", "D", "E")
    list1.Add (cols)
    cols = Array As String ( "F", "G", "H", "I", "l")
    list1.Add (cols)
    'This works well
End Sub [/ CODE]
Watching him with debugging seems that the newly inserted record with List1.add remains connected to the array of cols supporting, then the next assignment change the current record. The only difference is the method with i write cols, but to do
    cols (0) = "A"
    cols (1) = "B"
    cols (2) = "C"
    cols (3) = "D"
    cols (4) = "E"
It is not equivalent to do
    cols = Array As String ( "A", "B", "C", "D", "E")
?
Thanks and regards.
 

luciano deri

Active Member
Licensed User
Longtime User
Ok, so this is the right first metod?
B4X:
Sub EsempioLista
    Dim list1 As List
    list1.Initialize
    Dim cols (05) As String
    cols (0) = "A"
    cols (1) = "B"
    cols (2) = "C"
    cols (3) = "D"
    cols (4) = "E"
    list1.AddAll (cols)

    cols (0) = "F"
    cols (1) = "G"
    cols (2) = "H"
    cols (3) = "I"
    cols (4) = "L"
    list1.AddAll (cols)

end Sub
 

luciano deri

Active Member
Licensed User
Longtime User
OK thanks. I have many elements to be included and I prefer to see them in columns rather than in a long line
 
Top