08-02-2013 04:41 PM
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
08-02-2013 04:44 PM
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.
08-02-2013 04:53 PM
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
08-02-2013 04:55 PM
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.
08-02-2013 05:11 PM
No... I m displaying the data in frontpanel
08-02-2013 05:20 PM - edited 08-02-2013 05:22 PM
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
08-02-2013 05:44 PM
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
08-02-2013 05:52 PM
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.