02-15-2007 08:59 AM
02-15-2007 09:05 AM
02-15-2007 10:52 AM
BC@Baxter wrote:
...The STRING-TO-HEX and STRING-TO-BINARY functions are not applicable in this case because the bytes were not string type in the first place...
Of course they are string type, just not formatted in a human readable form. So, YES, these functions are not appropriate.
BC@Baxter wrote:
For example, if the receive byte is 0x4D, I need to display 4D in HEX or 77 in Decimal and not the ascii character "M" corresponding to 0x4D ascii code.
Dennis is right, but there is no "decimal" display for strings, so the second requirement needs a tiny little bit more code.
If you have a single byte string, you can typecast it into a U8 number and set the display format as decimal, hex, octal, or binary as desired. In decimal, it would display the number 77. Since it is now a numeric, you can even do math with it. 🙂
In general, the string has multiple bytes, and you would typecast it into an array of U8 numbers (Since this is an often used function, there is also a "string to byte array" which does the same thing).
Typecasting is the secret. You can e.g. easily typecast 2 bytes into a U16, 4 bytes into a I32, 8 bytes into a DBL, etc. For more detailed requirements, there is also the "unflatten from string". Check the online help for details. Good luck!
02-15-2007 11:50 AM