01-29-2021 02:06 AM
Hi, I am new to Labview and trying to convert a c example to labview. I am stuck on how to do the below statement in C in Labview
sprintf (Command , "11004%c1%c%d\r", 182, 182, 1);
I tried using Format to String, but not able to figure out how to do the %c part to send out delimiter.
Thank you.
01-29-2021 02:40 AM - edited 01-29-2021 03:01 AM
Create a U8 numeric constant with value 182 (drop it from the Numeric palette then right click on the constant-> Representation -> U8), then Type Cast it to a String (or use Flatten To String), to be found in the Numeric -> Data Manipulation palette . Use %s accordingly.
If you have more than one character to convert (i.e. a string with length > 1), make a U8 array and use Byte Array To String in palette String -> Path/Array/String Conversion.
One further possibility is to directly embed the constant into the format string, changing the format string's Display Mode to '\' Codes and including the constant as \B6 (its hexadecimal representation preceded by the escape character \).
01-29-2021 04:38 AM
182 is B6 in hex, so if the values are static you can simply use "11004\B61\B6%d\r" as an input to format into string. Or simply "11004¶1¶%d\r".