Problem string processing

FFMan

Member
Licensed User
Longtime User
I have some code that is processing incoming strings from a bluetooth connection. Each string starts with STX chr(2) and ends with ETX chr(3) followed by a 2 byte checksum.

B4X:
       msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
      strRCV=strRCV & msg
      
      inSTX=strRCV.IndexOf(Chr(2))
      inETX=strRCV.IndexOf(Chr(3))
      Log("Got=" & msg)
      Log("RCV=" & strRCV)
      Log(inSTX & "," & inETX & "," & strRCV.Length)
problem is inETX is always zero even though i can see from the logging that the string contains 1 or more STX characters. inETX gets the correct value.

I'm new to b4a though proficient with VB6 and zbasic so its probably just a newbie error - any help much appreciated.
 

FFMan

Member
Licensed User
Longtime User
ah ok - starting from zero

sorry - newbie thing - haven't encountered this numbering before - you live and learn.

thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…