LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert string to numeric of same digits

Hi,

 

   I am a beginner to labview... I have to convert a string to number of exact digits... I have tried using decimal string to number conversion. I get the number but the digits are not same..

 

 

  Eg, Input String is 0001.

 

         What i get is 1.

 

          What i need is 0001 in numeric.

 

   Thanks in advance...

 

Regards,

Raj

0 Kudos
Message 1 of 8
(3,186 Views)

You can change the display format for a numeric indicator. Right click on the indicator and select "Display Format". There you can specify the number of digits to display and whether or not to include leading 0s. The number itself is simply 1 no matter how it is displayed.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 8
(3,184 Views)

Thanks,

 

          But i m not using a indicator... I am trying to generate serial number of 4 digits using add function.. If the number is just 1 then the output will be 2..

What i need is 0002,0003,0004............. and so on...

 

Hope understand my problem

0 Kudos
Message 3 of 8
(3,180 Views)

What are you doing with the data? If you ar esending it out via a serial port or something like that it will be 4 bytes if you use a 32-bit integer. The number of bits the number has will dictate what is transmitted.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 8
(3,177 Views)

No... I m displaying the data in frontpanel

0 Kudos
Message 5 of 8
(3,172 Views)

The number itself isn't changing (outside of the serialization), as Mark mentioned a 9 is a 9 regardless of what it looks like (11 octal, 9 hex, 1001 binary... 0000009.00, 9.0... all still "9").  String and Numeric are the same thing, even though they look different.

 

So format the (d)ecimal number into a string and pad it with zeroes (%0) to a length (4).

 

>pic related

 

0 Kudos
Message 6 of 8
(3,166 Views)

I have attached the vi for better understanding.. I have to replace 8 characters.. If i leave trailing zeros then i will get only 4 digits.

 

Correct me if i am wrong..

 

Regards,

Raj

0 Kudos
Message 7 of 8
(3,154 Views)

What you had originally posted i snot what you are ultimately trying to do. You are converting the number back into a string. Also, you have the model number to contend with.

 

Try this. It build the string size and accounts for the length of the model number.

 

Ba printer auto indexing not ok.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 8
(3,151 Views)