LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retaining units of a control when converting to a string

I have controls which have units (mm, um, nm .etc . . .) and I am serializing them for string presentation in reports but the units are always cast to the base. So If I pass 2.5 mm and convert it to a string using %f format I get back 0.0025 m. I would like to retain the units I pass to the "Format Into String" VI. Is this possible? What do I have to do? Help please.
-Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 1 of 5
(2,145 Views)
Salutations,

I believe i've discovered the holy grail for your solution. In the "Format Into String.vi" use the context help, then click on the "format string" link that's inside of the "format string" section. Next find "format specifiers" at the base of the page. Click this link and it'll take you to a place that gives you a lot of information.

Your solution, could be as simple as making the "format string" specification spot into a %p.

Best wishes,
ElSmitho
Message 2 of 5
(2,132 Views)
ElSmitho,

%p almost works, this does keep the prefix on the units but places the prefix on the number followed by a space and then the units so 2.5 mm translates to "2.5m m" this is almost correct but I dont see an easy way arround it. Thanks for the help
-Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 5
(2,123 Views)
Use the Search and Replace String primitive to remove the space after you have formatted the number. The attached image shows this process. Note that the space string has '\' Codes Display selected from the pop-up menu to show that it is a space character. In normal display, it would appear to be an empty string constant. If you are unfamiliar with the other input, it is an Empty String Constant.
This account is no longer active. Contact ShadesOfGray for current posts and information.
0 Kudos
Message 4 of 5
(2,109 Views)
Thanks, Looks like I will have to write a subvi which will convert a number with units to string and another vi which does it in reverse, I was hoping to save time and just use the standard string library but no such luck maybe in a future release there will be an option to conserve the units and prefix with the correct spacing.

-Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 5
(2,098 Views)