Bug? List with Map not the same as in B4a?

D

Deleted member 103

Guest
Hi Erel,

the same data with the same routine deliver different results.
Is the map stored differently?

I ask because I've used in B4a this procedure for the conversion, and now no longer works in B4i.
B4X:
  Dim lst As List   
  lst=File.ReadList(File.DirLibrary, "Setup.ini")

  For i = 1 To Timerlist.Size -1

    mp = ConvertStringToMap(list.get(i))
 Next

Sub ConvertStringToMap(str As String) As Map
    Dim mp As Map
    Dim strMap() As String
    Dim strList() As String

    mp.Initialize
    If str<>"" Then
        str = str.SubString2(1, str.Length -1)
        strMap=Regex.Split(",",str)
       
        For i = 0 To strMap.Length -1
            strList=Regex.Split("=",strMap(i))
           
            If strList.Length = 2 Then
                mp.Put(strList(0).Trim, strList(1).Trim)
            Else
                mp.Put(strList(0).Trim, "")
            End If
        Next
    End If
    Return mp
End Sub

List+Map_B4a-B4i.JPG
 
D

Deleted member 103

Guest
Hi Erel,

this is no longer necessary, I use now another routine to save and to read.
 

imbault

Well-Known Member
Licensed User
Longtime User
@Filippo , I have the same pb with maps, handling, storing, can you, please, share your code for b4i, please
 
D

Deleted member 103

Guest
@Filippo , I have the same pb with maps, handling, storing, can you, please, share your code for b4i, please
This is the code I'm using now.
B4X:
Sub ConvertStringToMap(str As String) As Map
    Dim mp As Map
    Dim strMap() As String
    Dim strList() As String

    mp.Initialize
    If str<>"" Then
        str = str.SubString2(1, str.Length -1)
        strMap=Regex.Split(",",str)
       
        For I = 0 To strMap.Length -1
            strList=Regex.Split(":",strMap(I))
           
            If strList.Length = 2 Then
                mp.Put(strList(0).Trim, strList(1).Trim)
            Else
                mp.Put(strList(0).Trim, "")
            End If
        Next
    End If
    Return mp
End Sub
 
Top