A AndyDroid2012 Member Licensed User Longtime User Feb 15, 2013 #1 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. Code: Copy 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 Code: Copy "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.. Code: Copy 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() ?
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. Code: Copy 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 Code: Copy "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.. Code: Copy 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() ?
Erel B4X founder Staff member Licensed User Longtime User Feb 17, 2013 #2 s is a string. Calling Array As String(s) only wraps it in an array. The correct code: Code: Copy List1.AddAll(Regex.Split(",", s)) Upvote 0
s is a string. Calling Array As String(s) only wraps it in an array. The correct code: Code: Copy List1.AddAll(Regex.Split(",", s))