LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Leading zeros in numeric control

Solved!
Go to solution

Got it, but is there a way to change it dynamically by reading the length of the serial number with leading zeros. 

0 Kudos
Message 11 of 21
(1,478 Views)

Sure, just replace the 6 with however many characters are in the serial number.

 

Capture.PNG

Message 12 of 21
(1,471 Views)

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".

Message 13 of 21
(1,470 Views)

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

0 Kudos
Message 14 of 21
(1,466 Views)

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

0 Kudos
Message 15 of 21
(1,449 Views)

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).

0 Kudos
Message 16 of 21
(1,460 Views)

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?

 

0 Kudos
Message 17 of 21
(1,453 Views)

Sorry, it should be spelled RavenFans and not RyanEvans

0 Kudos
Message 18 of 21
(1,448 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 19 of 21
(1,417 Views)

Well, irrespective of that, the numeric control in general drops the leading zeros, that's where I was asking about the suggestion. 

0 Kudos
Message 20 of 21
(1,407 Views)