Convert array of Bytes to one string?
Erlend
Posts: 612
Instead of comparing a byte array with an other, byte by byte, I had the idea to convert them to stings and do a Strcomp of the two.
How can I do this conversion?
dataRFID is declared as a Byte[12] where the first and last byte is not used.
strngRFID is declared in the parent object as a LONG[11], and the pointer is passed
Learning, learning,
Erlend
How can I do this conversion?
dataRFID is declared as a Byte[12] where the first and last byte is not used.
strngRFID is declared in the parent object as a LONG[11], and the pointer is passed
repeat i from 1 to 10 'For each byte LONG [strngRFID] [i-1] := dataRFID[i] 'Copy to string variable LONG [strngRFID] [11] := 0 'Convert to zero-terminated string
Learning, learning,
Erlend
Comments
Except of course if the data in your byte array happens to contain zeros....
Anyway, bytes-to-string works fine.
Erlend
maybe it is just that you are using longs.
To use strings in SPIN you have to define an array of BYTE not of longs
Your debugging will be much easier if you start with less complex constructions
and if you start with democode where all things are well known to work properly.
Start with a democode just doing "Hello world"
then start changing this code in smallps
I mean something simple like this
modify this code in small steps.
25 years of programming learned me if you want it to work superfast (coding it all at once an start testing if first version is finished) it will turn out superslow
because there are so many places where the bug COULD be.
Start with working democode and change it in small steps. Testing after EACH change will turn out to be faster because the bug must always be in the LAST change.
best regards
Stefan
Erlend