LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a string that contains delimiter to control an instrument

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.

 

0 Kudos
Message 1 of 3
(949 Views)

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 \).

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 3
(934 Views)

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".

0 Kudos
Message 3 of 3
(905 Views)