PyJoin() - Returns a string in which the string elements of the given sequence (list / array) have been joined by glue separator.
Usage:
Snippet:
Usage:
B4X:
Dim strArray() = Array As String("I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII") As String
Dim strList As List : strList.Initialize : strList.Add("A") : strList.Add("B") : strList.Add("C") : strList.Add("D")
Log(PyJoin(", ", strArray))
Log(PyJoin("-", strList))
'Output:
'I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII
'A-B-C-D
Snippet:
B4X:
Sub PyJoin(glue As String, strList As Object) As String
Dim lst As List
Dim out As String
If GetType(strList) == "[Ljava.lang.String;" Then
lst.Initialize
Dim arr() = strList As String
lst.AddAll(arr)
Else
lst = strList
End If
For Each str As String In lst
out = out & str & glue
Next
Return out.SubString2(0, out.Length - glue.Length)
End Sub
Last edited: