Bug? Possible Map bug?

Antonio

New Member
Licensed User
Hi all,

If you check the follow routine, the Map code should have one char (for each put) from string Test.

At the end, code will have only the result "01" instead of "010101" without arise exceptions.

If j use the string test = "W0DD5J" the result code = "W0D5J" (one D is missing)

If j use the string test = "0M590N" the result code = "0M59N" (the second ZERO is missing)

J did only these tests, and if it's a bug, there will be other kinds of combinations to get these exceptions.

J use B4A 4.0



B4X:
Sub Activity_Create(FirstTime As Boolean)

    If FirstTime Then

        Dim Test As String = "010101"
        Dim code As Map
        code.Initialize()

        code.Put(Test.CharAt(0) , Test.CharAt(0) )
        code.Put(Test.CharAt(1) , Test.CharAt(1) )
        code.Put(Test.CharAt(2) , Test.CharAt(2) )
        code.Put(Test.CharAt(3) , Test.CharAt(3) )
        code.Put(Test.CharAt(4) , Test.CharAt(4) )
        code.Put(Test.CharAt(5) , Test.CharAt(5) )
Thanks
 

JohnD

Active Member
Licensed User
It seems like a list might suit your purposes here.

B4X:
Sub Activity_Create(FirstTime As Boolean)

If FirstTime Then

    Dim Test As String = "010101"
    Dim lst As List
    Dim i As Int
    lst.Initialize

    For i = 0 To Test.Length - 1
        lst.Add(Test.CharAt(i))
    Next

    For i = 0 To Test.Length - 1
        Log(lst.Get(i))
    Next
   
End If

End Sub
You might also want to look at the multi-dimensional array post on this forum.
 
Top