I am new to the forum, but have been using labview for a while. Finally found something that really stumped me, hope I can find someone who is smarter than me! It may be an obvious thing too, but here it goes. The vi attached is the root cause of the error. I have a serial number that I need to convert from a decimal string into a number, I later use the number for "math" so need it in number form. The system always receives a 6 character serial number (ie. 123456), but today the system received a serial with two zeros preceding the ladder digits (ie. 003456). This set off all the alarm bells down stream (4 digits sent), but tracing the error found it started at the "smarts" at the beginning for the program. I would like to know if there is a way to force the the Decimal Number to String to not shave the preceding zeros off of the 6 digit value.
File is in LabVIEW 2014
Any thoughts or comments, Thanks!
Solved! Go to Solution.
The problem is not the string functions. It is the display format for your numeric indicator. Change the properties on that.
You are correct, that did fix the "Indicator" but the value if probed is only the four digits. I need to use the data later with the padded zeros. Thanks for the help!
When you have a number, it is a number. What it looks like probed or displayed doesn't change the number. 001234 is equal to 1234. The only difference is the way they are displayed. If you need a probe on a wire to show it with padded zeroes, then create a custom probe.
Thanks the help, I do agree with you. I created a work around that fixed my problem. I appreciate your time!
By any chance, are you trying to comapre these serial numbers as floating point numbers? This will cause problems if you do calculations to reach the any of the serial numbers. While integers are represented exactly in FP numbers, if you did any kind of calculations using or resulting in fractional numbers, you may have comparison issues.
Maybe you can describe or upload your workaround so others can benefit from your acquired wisdom. 😉
Thanks for the interest billko, the png attached is my work around. The issue started during the input, so two values are captured: original serial string length & post decimal string to number conversion length. The difference is then fed into a simple state machine that dictates the amount of zeros to be added or ignored. The state machine can handle, no change, 0,00,000,0000 zeros. It then concatenates the correct number of zeros as needed for each serial number. Works great!
Technically that is not a state machine. Those are just case structures.
Now you are working with strings again, when originally you were complaining that the numeric indicator and probes weren't showing leading zeroes.
All of that is just complicated Rube Goldberg Code
Just use Format into String.
lol, I like that terminology. That is much simpler, I will have to use it. Thanks for your expertise, learned something new today!