1. The Godfather
2. Citizen Kane
3. Casablanca
4. Schindler's List
5. Pulp Fiction
6. The Shawshank Redemption
7. 2001: A Space Odyssey
8. The Dark Knight
9. Fight Club
10. Forrest Gump
I search for several codes in the forum, but I only found this way (save the string to file and read to a list)
B4X:
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
File.WriteString(xui.DefaultFolder, "1.txt", j.GetString)
lstResponse = File.ReadList(xui.DefaultFolder, "1.txt")
End If
Is possible to generate a list from this string response without save and read the file?
i don't fully agree with the selections on the list, but i would use regex.split() and list.addall().
i'm guessing the string uses crlf (or possibly "\r\n", depending).
so split the string on crlf to get an array of strings and then create a list and
call addall.
dim result as string = job.getstring
dim films() as string = regex.split(crlf, result)
dim filmlist as list
filmlist.addall( films )
i don't fully agree with the selections on the list, but i would use regex.split() and list.addall().
i'm guessing the string uses crlf (or possibly "\r\n", depending).
so split the string on crlf to get an array of strings and then create a list and
call addall.
dim result as string = job.getstring
dim films() as string = regex.split(crlf, result)
dim filmlist as list
filmlist.addall( films )
I search for several codes in the forum, but I only found this way (save the string to file and read to a list)
B4X:
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
File.WriteString(xui.DefaultFolder, "1.txt", j.GetString)
lstResponse = File.ReadList(xui.DefaultFolder, "1.txt")
End If
Is possible to generate a list from this string response without save and read the file?
Dim Text As String = $"1. The Godfather
2. Citizen Kane
3. Casablanca
4. Schindler's List
5. Pulp Fiction
6. The Shawshank Redemption
7. 2001: A Space Odyssey
8. The Dark Knight
9. Fight Club
10. Forrest Gump"$
Log("** Use Array **")
Dim OutArray() As String = Regex.Split("./",Text)
For Each s As String In OutArray
Log(s)
Next
Log("--------------------")
Log("** Use List **")
Dim OutList As List = Regex.Split("./",Text)
For Each s As String In OutList
Log(s)
Next