it appears that the pad function is incorrect. the "for" line adds one too many characters. it should be (length - text.length - 1). or am i missing something?
B4X:
Sub Pad (Text As String, PadWith As String, Length As Int, Post As Boolean) As String
'Classic
Private Str As String = ""
Private FillStr As String
If PadWith= "" Then PadWith = "*"
For i=0 To Length - Text.Length
FillStr = FillStr & PadWith.CharAt(0)
Next
If Post Then
Str = Text & FillStr
Else
Str = FillStr & Text
End If
Return Str
End Sub