i think the trim function doesn't work properly
the function should trim the spaces at the end of a string
but it also trims the characters with ascii code below 32
here is the sample code:
program output:
source string
index = 0 ascii = 1
index = 1 ascii = 2
index = 2 ascii = 3
index = 3 ascii = 4
index = 4 ascii = 5
index = 5 ascii = 6
index = 6 ascii = 7
index = 7 ascii = 8
index = 8 ascii = 9
index = 9 ascii = 10
trimmed string
(no output)
tanks
the function should trim the spaces at the end of a string
but it also trims the characters with ascii code below 32
here is the sample code:
B4X:
Dim s As String
Dim t As String
Dim j As Int
s = ""
For j = 1 To 10
s = s & Chr(j)
Next
t = s.Trim
Log ( "source string" )
For j = 0 To s.Length - 1
Log ( "index = " & j & " ascii = " & Asc ( s.CharAt(j) ) )
Next
Log ( "trimmed string" )
For j = 0 To t.Length - 1
Log ( "index = " & j & " ascii = " & Asc ( t.CharAt(j) ) )
Next
source string
index = 0 ascii = 1
index = 1 ascii = 2
index = 2 ascii = 3
index = 3 ascii = 4
index = 4 ascii = 5
index = 5 ascii = 6
index = 6 ascii = 7
index = 7 ascii = 8
index = 8 ascii = 9
index = 9 ascii = 10
trimmed string
(no output)
tanks
Last edited by a moderator: