Hi Jeremy; Your point is quite valid, and the OP may want to consider it as it relates to what he is trying to accomplish. The OP described sending ascii text that depicted the hex characters. ?Don¡¯t know why, but that was what he showed, and it could very well actually be not what he really wants to do. ? I read the question as asking how to get the data from the input of his module into the makestring. ?I answered that question, not whether what he asked how to do made sense. ?Who knows, maybe the string he was trying to generate eventually gets parsed by looking for ¡°\x¡±, can¡¯t read minds. The real meat of my post was how to extract individual bytes from a long integer so he could do whatever he wants with them. ?Again, if he wanted to just send the hex bytes representing the value he should have been able to just use something like %04lX as a specifier and drop the long integer right into makestring. From: <Crestron@...> on behalf of "Jeremy Weatherford jweather@... [Crestron]" <Crestron@...> Reply-To: <Crestron@...> Date: Thursday, January 3, 2019 at 8:47 PM To: <Crestron@...> Subject: Re: [Crestron] String ?
INTEGER byte1; byte1 = 42; makestring(TX, "\\x%02X", byte1); // this sends 4 characters to TX, a literal backslash, literal x, a 2, and an A makestring(TX, "%c", byte1); // this sends 1 character to TX with the value 42 or \x2A Compiles and runs != working as intended Debugger will happily show you the literal string "\x2A" even though it's not what you were intending to send.? Switch to all hex mode and you'll see \x5C\x78\x32\x41.? Mixed mode can really screw you up, especially when you're looking for what you expect to see.
|