### Left, Mid and Right String

These are String Left, Mid and Right subroutines.
Note that there is no error handling. Start position is 1 and not 0.
Dim s As String = "123456789"
Log($"${s} = StrLeft(3) ${StrLeft(s, 1)}"$)
Log($"${s} = StrMid(4,6) ${StrMid(s, 1, 6)}"$)
Log($"${s} = StrRight(4) ${StrRight(s, 4)}"$)
`Sub StrLeft(s As String, l As Int) As String
Dim Result As String = s
Return Result.SubString2(0, l)
End Sub`
`Sub StrMid(s As String, b As Int, e As Int) As String
Dim Result As String = s
Return Result.SubString2(b - 1, e)
End Sub`
`Sub StrRight(s As String, r As Int) As String
Dim Result As String = s
Return Result.SubString2(r + 1, Result.length)
End Sub`
Example with Error Handling
'Gets the leftmost len characters of a String.
'Example: LeftString(s, 20)
`Private Sub LeftString(s As String, len As Int) As String
If s = Null Then Return ""
If s.Length <= len Then
Return s
Else
Return s.SubString2(0, len)
End If
End Sub`

Changed: , Category: Strings, File: T6C255M1854.htm, ID: 1854