Storing FloatToFormat String result into a byte array
4Alex
Posts: 119
Hi there!
I am trying to transfer each individual characters resulting from the FloatToFormat function into a byte array without success. The function works perfectly when its output is directed toward Hyperterminal. Now, I· want the byte array to be the recipient of the characters instead of Hyperterminal. I have attempted several different approaches and couldn't find something working. I am quite 'green' on the PPL (just a few months hand-on), love the device, but I find the logic somewhat different from other microprocessors I used so I must miss something evident. My searching of the previous posts was also inconclusive. Could a compassionate soul point me in the proper direction, please.
Here's what I try to do (kind of pseudo-code):
var ...
byte buffer [noparse][[/noparse] 20 ]
.
pub...
.
cptr := 11
inc := 0
repeat 6
· buffer [noparse][[/noparse] cptr++ ]· := floatStr.FloatToFormat(temperature, 6, 1)
.
Thanks for your help.
Alex
I am trying to transfer each individual characters resulting from the FloatToFormat function into a byte array without success. The function works perfectly when its output is directed toward Hyperterminal. Now, I· want the byte array to be the recipient of the characters instead of Hyperterminal. I have attempted several different approaches and couldn't find something working. I am quite 'green' on the PPL (just a few months hand-on), love the device, but I find the logic somewhat different from other microprocessors I used so I must miss something evident. My searching of the previous posts was also inconclusive. Could a compassionate soul point me in the proper direction, please.
Here's what I try to do (kind of pseudo-code):
var ...
byte buffer [noparse][[/noparse] 20 ]
.
pub...
.
cptr := 11
inc := 0
repeat 6
· buffer [noparse][[/noparse] cptr++ ]· := floatStr.FloatToFormat(temperature, 6, 1)
.
Thanks for your help.
Alex
Comments
This copies 20 bytes regardless of the actual length of the string, but the copy is very fast and it doesn't matter that extra bytes (beyond the zero terminator) are copied as well.
Thank you very much for your kind reply. I am soooo embarassed: I did try something similar but I stupidly put the @ sign in front of the floatStr.FloatToFormat !!! I even tried @@... (which obviously I still don't get, but that's another story). I thought it was the only way to indicate that I wanted to start at the beginning of the string result.
Thank you again for your help.