Android Question read data from byte

wiwit

Member
Licensed User
Longtime User
https://www.b4x.com/android/forum/threads/int-value-from-byte.70592/#content

B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private bc As ByteConverter
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   ReadDate("01.09.2016 16:49:45")
End Sub

Sub ReadDate(data() As Byte)
  Log("Date time>>",data)
   'step 1: get the correct substring
   'step 2: convert it to string as array of bytes cannot be directly converted to numbers
  Dim day As Int = bc.StringFromBytes(bc.SubString2(data, 0, 2))
  Dim month As Int = bc.StringFromBytes(bc.SubString2(data, 3, 5))
  Dim year As Int = bc.StringFromBytes(bc.SubString2(data, 6, 10))
   Log(day, "/", month, "/", year)
End Sub


Error description: Unknown member: substring2

Dim S1 As Int = bc.StringFromBytes(bc.SubString2(msg, 0, 3))
Word: substring2

is there something wrong?
I use it in B4a
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
ByteConverter does not have a Substring2, only strings have...
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
That's an example from B4R. Only the Byteconverter from B4R has a substring2 implementation.
 
Upvote 0
Top