LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make labview discard user typed units

Solved!
Go to solution

I am currently using a format string to display the units of a text control in line with the value.  The desired format is the number, followed by a space and then the units.  This works well for just displaying the value, but if the user types a new value and erases the space by mistake, the change is rejected.  As an example:

 

x = 15, control reads "15 mA", if the user starts to type a new value but accidently erases the space and enters "20mA", their change is rejected.  It looks like labview is trying to parse the user input as an entered unit, in the same way that typing "1m" in a numeric control results in a value of .001.  Is there a way to force labview to discard any user typed units on a numeric control?

 

I would like to keep the unit printed in the numeric text and keep the space if possible, as it looks cleaner than adding it into the control's caption or into a separate unit label. I'd also like to avoid using a separate string control and having to programatically parse the value.  I've attached an example vi (in 8.6), simply type a new number into the bottom control and observe the new value, don't even have to run the vi.

 

Have searched around but can't find the answer.  Thanks for the help.

 

Edit: my format string is: "%#g mA"

0 Kudos
Message 1 of 8
(3,614 Views)
Solution
Accepted by topic author ande3577
Message 2 of 8
(3,586 Views)

Indeed it does.  Thanks for linking to the thread.  Tried searching but didn't see that one.

 

A subtle difference in that I'm not seeing it reset to 0 on every other entry, but definitely sounds related.

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

I think that this is potentially a quite dangerous bug and it is actually not the same as the reset to zero bug.

 

Take, for example, a pressure controller. For the pressure setpoint you may use a control with the display format set to "%0.1f Torr". The user will see the pressure setpoint as #.# Torr. If, by mistake, they erase the space between the number and the unit when entering a new setpoint, LabView will decide that they are asking for #.# TeraTorr. That is 12 orders of magnitude larger than they want!

 

I have confirmed that this bug is still present in LV 2012 (Version 12.0.1f3).

 

Test code is attached.

 

 

Message 4 of 8
(3,380 Views)

Omen101,

 

I have reproduced this myself and am looking to see if this is a known bug or not.  If not, I will file a CAR to have this corrected.  Thank you for pointing this out!

Jesse S.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 8
(3,345 Views)

Its worth pointing out that this also happens for any standard SI unit prefix. For example, removing the space when the units are "ktorr" gives me 1000x my value.

 

Also note that if the character following the SI unit prefix is capitalized, there will be no problem. For example, the display format "%0.1f kPa" does not cause any trouble when the space is removed during data entry.

 

Any chance of getting this topic marked as unsolved?

 

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

The original poster's question was solved.  They had a problem, and found out it was related to a LabVIEW bug.

 

Then the message thread was recently revived with when a similar, (in that it related to units) but somewhat different bug seems to be asked about.  An NI engineer responded that there is a CAR identified for this bug.

 

Nobody says the bug itself has been solved.

 

Bug solving in NI's CAR system is completely different then a solved question on the discussion forums.

Message 7 of 8
(3,305 Views)

There is now a CAR for this bug.  It is #416215.

Jesse S.
Applications Engineer
National Instruments
0 Kudos
Message 8 of 8
(3,286 Views)