Hi!
I've made a program that get 8 bytes of data from the comport and store them in a string. I use the CVBYTE$ function to split the 8 bytes from the string to separate byte variables. But.. I want to display the number stored in one of the bytes in a listbox. But it seems like I need to convert it back to a string to display it, but then the computer reads the number as a ASCII value and show up a letter. Sorry my poor english... Hehe.. but I hope you understand what I mean.
Here's a snippet that show how i convert the string to byte variables..
Comm Recv #2, BytesInBuffer, datamottak
typ = CvByt(datamottak, 1)
node = CvByt(datamottak, 2)
kommando = CvByt(datamottak, 3)
stat = CvByt(datamottak, 4)
verdi1 = CvByt(datamottak, 5)
verdi2 = CvByt(datamottak, 6)
verdi3 = CvByt(datamottak, 7)
verdi4 = CvByt(datamottak, 8)
What PB function are you using to convert from the number (byte) to a string?
I am think you simply need to use STR$ or FORMAT$ in this case.
I would suggest using a BYTE PTR to reference the values. For example:
LOCAL pbdatamottak AS BYTE PTR
DIM bytearray(7) AS BYTE
pbdatamottak = STRPTR( datamottak) 'Use VARPTR if datamottak is ASCIIZ
FOR I = 0 TO 7 'Base 0
bytearray( I) = @pbdatamottak[I] 'Access byte values
MSGBOX "Byte " + FORMAT$( I + 1) + " is " + FORMAT$( @pbdatamottak[I]) 'display byte values
NEXT
FORMAT$ simply solved my problem! Thanks a lot!