04-10-2018 12:31 PM
Got it, but is there a way to change it dynamically by reading the length of the serial number with leading zeros.
04-10-2018 12:39 PM
Sure, just replace the 6 with however many characters are in the serial number.
04-10-2018 12:39 PM
Scanners always read stuff in as a string. It became as number when someone in the code you have been using for a long time converted it from string to a number early in the process.
1. Read string of digits.
2. Convert string to number.
If you want to know how long the original number is including leading zeroes, you'll have to get that information back before step #2 where they threw away leading zeroes by converting it to a number.
0012345 is the same numeric value as 12345. The string "0012345" is a different string than "12345".
04-10-2018 12:47 PM
ok, this is when I know the length of my serial number before hand. But if I want to know the length before it goes into the numeric control (i.e before it drops the leading zeros) and reconstruct it using the format to string function you have shown, is it possible to do it at this stage. Thanks
04-10-2018 12:48 PM
Hi Greg,
ok, this is when I know the length of my serial number before hand. But if I want to know the length before it goes into the numeric control (i.e before it drops the leading zeros) and reconstruct it using the format to string function you have shown, is it possible to do it at this stage. Thanks
04-10-2018 12:57 PM
Nope, as RavensFan said that information is thrown away when it gets converted to a number. You would have to save the string length back above.
Alternatively, you could save the actual string read from the barcode scanner by creating a new variable for it. For instance : Serial Number (str). Adding an extra output to a VI may mean the TestStand calls have to be updated, but maybe not. At least it would not break the other VIs that use Serial Number (dbl).
04-10-2018 01:07 PM
Thanks Greg and RyanEvans.
I will try what Greg mentioned with another string variable in the tesstand for the purpose of use in my vi. I will update you guys if I see a problem. Also, can we suggest NI to have an option to leave the leading zeros in numeric control?
04-10-2018 01:09 PM
Sorry, it should be spelled RavenFans and not RyanEvans
04-10-2018 01:57 PM
@vvk07 wrote: Also, can we suggest NI to have an option to leave the leading zeros in numeric control?
That is purely based on your format for the numeric indicator. As has been said, that information is gone as soon as the string is converted to a number. Back to what RavensFan has been stating, you should never have had the number; you should have been using a string all along.
04-10-2018 03:10 PM
Well, irrespective of that, the numeric control in general drops the leading zeros, that's where I was asking about the suggestion.