Hi Erel,
While playing with the Strings and Bytes tutorial I tried to extract items from a string using Substring2 with strange results. Not sure if this a bug or not but Substring works as expected but not Substring2.
Using Substring the log shows
Using Substring2 the log shows
Also when I copy stuff from the logs window using "Copy all to clipboard", everything I copy is pasted backwards.
Thanks
PS. Really love B4R. Thanks for another great product
While playing with the Strings and Bytes tutorial I tried to extract items from a string using Substring2 with strange results. Not sure if this a bug or not but Substring works as expected but not Substring2.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim bc As ByteConverter
Dim b() As Byte = bc.Trim("abcdef ")
b(0) = Asc("M") 'this line will change the value of the literal string
Log("b length = ",b.Length)
Dim s As String = "abcdef "
Log(s) 'Mbcdef
Log("abcdef ") '???
For i = 0 To b.Length - 1
Log("b.",i," = ",b(i))
Next
Dim d As String
d = bc.StringFromBytes(b)
Log("d length = ", d.Length)
For i = 0 To d.Length -1
' this next line messes the Arduino up completly
' Log("d = ",bc.SubString2(d,i,1))
' this line works as expected
Log("d = ",bc.SubString(d,i))
Next
End Sub
Using Substring the log shows
Appstart
b length = 6
Mbcdef
abcdef
b.0 = 77
b.1 = 98
b.2 = 99
b.3 = 100
b.4 = 101
b.5 = 102
d length = 6
d = Mbcdef
d =bcdef
d = cdef
d = cd
d = c
b length = 6
Mbcdef
abcdef
b.0 = 77
b.1 = 98
b.2 = 99
b.3 = 100
b.4 = 101
b.5 = 102
d length = 6
d = Mbcdef
d =bcdef
d = cdef
d = cd
d = c
Using Substring2 the log shows
g������;�a��/��o����.���?���/��|�U߽:_���/o����U�z����3���.ӕ�k��������ws���?�ڻ�����[������������~�zַx~^�;���v͞]��{��V���}�����+>�˻�t��?��}�=Sٟv��������~���,{^���.�w�����ӹ��>(*�����ɹ�����5�yb���j�uO����k���.{���r�s�����{������[��E���g�����_����:�>�����3������?���{���뻽�������7��{��c?ܜ���_�o�~�n|�owս��Y}v�˟o���y�ۭ�����u�w����VcU��O����<������s�]�
Also when I copy stuff from the logs window using "Copy all to clipboard", everything I copy is pasted backwards.
d = fd = efd = defd = cdefd = bcdefd = Mbcdefd length = 6b.5 = 102b.4 = 101b.3 = 100b.2 = 99b.1 = 98b.0 = 77abcdef Mbcdef b length = 6AppStart
This is the info from the logs window but backwards. ie the first log line should be "Appstart"
This is the info from the logs window but backwards. ie the first log line should be "Appstart"
Thanks
PS. Really love B4R. Thanks for another great product