Cannot list.addall using string variable

AndyDroid2012

Member
Licensed User
Longtime User
Can you please explain what is wrong here.
I have this code to pull down a web-server directory of topics which is limited it to six entries during testing.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    HttpUtils.CallbackActivity = "Main" 'Current activity name.
    HttpUtils.CallbackJobDoneSub = "JobDone"
    HttpUtils.Download("Job1", b4a)
    List1.Initialize
End Sub



Sub JobDone (Job As String)
    Dim s As String
    Dim t As String     
    If HttpUtils.IsSuccess(b4a) Then
        s = HttpUtils.GetString(b4a)
        
'<debug here>

        List1.AddAll(Array As String(s))    'ONLY ONE BIG STRING ADDED INSTEAD OF 6
        t = List1.Get(3)
        Msgbox(t,"")
    End If
    Log(s)
End Sub

The test data is a set of 6 text strings each ending with a ~ delimiter and an integer.


At the point of debug string variable s has the value

B4X:
"1929 Trades Directory~50","21 Tales of Wit~121","2nd Lieutenant Andrew Stewart~44","A History of Education ~108","A History of Education in Carluke Parish~107","A pleasant memory~126","---"
but it always ends up as a single entry in the list , with all my data in one entry.
Continuing gets a failure when attempting to read entry #3, part of my test.

What is the problem ?




This code below works, but seems to be more complex than necessary..
B4X:
Dim strSplit() As String
strSplit=Regex.Split(",",s)    
  For i = 0 To 6
    List1.add( strSplit(i) )
  Next
Does b4a not have something like the PHP function explode() ?
 
Top