LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Into String prob.

Hi,
 
I have a problem with using the string function "Format Into String". I have wired lots of different elements to it that works just fine, but with one input I can not get the desired effect. I have wired an numeric control that can control numbers and output numbers in the range of 0 to 65535.
 
The problem is that I need a string of 5 chars at all times, that is an output of the ´format into string´ that is int the range of 00000...65535. Is there any settings under the properties tab for the numeric control that I am missing, or is there a better way to get this working. I really want to use the Format Into String function for this. I app. any hints !
 
Kind regards
/P, newbie
0 Kudos
Message 1 of 4
(2,986 Views)
Use a format string of %05d.
0 Kudos
Message 2 of 4
(2,982 Views)

Dear Beagles:

         Format string is 5%d,I have already tried it.

 

0 Kudos
Message 3 of 4
(2,976 Views)


@moto_zhang wrote:
         Format string is 5%d,I have already tried it.
moto-zhang
Please don't post incorrect information, 5%d is not even a valid format string for this problem! (It would turn e.g. an input of 17 into a string of 517). 😞
 

@Beagles wrote:
The problem is that I need a string of 5 chars at all times, that is an output of the ´format into string´ that is int the range of 00000...65535. Is there any settings under the properties tab for the numeric control that I am missing, or is there a better way to get this working. I really want to use the Format Into String function for this. I app. any hints !

Beagles
Just to clarify, the properties of the numeric control only determine how the number in the control is displayed, it has no influence on the internal representation or later formatting operations. This is purely cosmetic. Still if you want your control also to display 5 digits with leading zeroes, right-click on it and select format&precision. Now choose:
-zero digits of precision
-minimum field width=5
-pad with zeroes on the left.
 
As mentioned before, use a %05d as a format when using "format into string". (The "%" identifies it as a formatting operation, the "0" causes leading zeroes to be displayed, the "5" forces a minimum widht of 5 characters and the "d" formats it as decimal integer.)
 
Attached is a small demo that illustrates this (LabVIEW 7.0). It also shows a plain numeric indicator set to display in the same way.
 
0 Kudos
Message 4 of 4
(2,955 Views)