B4R Question toUpperCase() / toLowerCase()

mrred128

Active Member
Licensed User
Longtime User
In arduino c, the string object has toUpperCase() and toLowerCase() functions. B4R does not and I believe the strings in B4R don't use the same objects. Is there any way to easily perform these functions without breaking the stack?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Process_Globals
   Public Serial1 As Serial
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   Dim s() As Byte = "abcDEF-123"
   ToUpper(s)
   Log(s)
   ToLower(s)
   Log(s)
End Sub

Sub ToUpper(s() As Byte)
   For i = 0 To s.Length - 1
     If s(i) >= 97 And s(i) <= 122 Then
       s(i) = s(i) - 32
     End If
   Next
End Sub

Sub ToLower(s() As Byte)
   For i = 0 To s.Length - 1
     If s(i) >= 65 And s(i) <= 90 Then
       s(i) = s(i) + 32
     End If
   Next
End Sub
 
Upvote 0
Top