LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make front panel control not accept values outside limits property?

Solved!
Go to solution

Hello,

 

I know that if a user enters a value for a front panel control that is out of range, there is an option where you can coerce the control to a min/max value as described by:

https://zone.ni.com/reference/en-XX/help/371361R-01/lvprop/abstime_outofrangeaction/

 

However is there any way to make it so that the control does not accept a value out of range and keeps the previous or default value for that control?

 

For example, suppose I have a front panel control X whose range is 0 to 10.  Suppose the value was set to 5 previously and then the user enters 44 by mistake.  Is there a way to make the control X keep the value 5 rather than coercing X to the max value of 10?  

 

Thanks,

Kevin 

0 Kudos
Message 1 of 10
(2,817 Views)

While the controls don't have that functionality, you are free to program around it as you wish. Shouldn't be too hard. Remove the limits from the control "data entry" and do an "in range and coerce in a value change event where you would write back the oldval (from event data node) to a local variable of the control if the newval is out of range.

0 Kudos
Message 2 of 10
(2,808 Views)

Something like this should work for what you are looking for. Note the case for value change of the Input Number. Inside that case it checks if the number is in range. If it is, it passes the value. If it is not in range it passes the old value for Input Number to the output array.

 

Snip1.pngSnip2.png

0 Kudos
Message 3 of 10
(2,719 Views)

@StevoP80 wrote:

Something like this should work for what you are looking for. Note the case for value change of the Input Number. Inside that case it checks if the number is in range. If it is, it passes the value. If it is not in range it passes the old value for Input Number to the output array.


This does not solve the problem of changing the control itself to the old value as requested (I already outlined the solution to that). Also your case structure contains 99% identical code, all you need is a "select" on the value. You can delete the case structure. Right?

0 Kudos
Message 4 of 10
(2,691 Views)

What do you think about this approach? You define your limits on the control, Ignore response to value outside limit.

 

You catch the value change like this, if the value is outside limits, you force it back to previousValue.

 

Limit_NoCoercion.png

0 Kudos
Message 5 of 10
(2,679 Views)

@altenbach wrote:

 

This does not solve the problem of changing the control itself to the old value as requested (I already outlined the solution to that). Also your case structure contains 99% identical code, all you need is a "select" on the value. You can delete the case structure. Right?

So change the Output Array to a property node for the value of Input Number and write the old value back to the control.

 

Sure the case structure isn't entirely necessary, but in my opinion it made it a little easier to read which is what I chose to go for since the OP was asking questions about some relatively simple LV concepts.

0 Kudos
Message 6 of 10
(2,671 Views)

@JICR wrote:

What do you think about this approach?


Yes, that works fine and is basically what I suggested. I probably would read the limits once before the toplevel loop (unless the limits can change during execution).

0 Kudos
Message 7 of 10
(2,670 Views)
Solution
Accepted by KevinBachovchin

I thought this would be even better.

If you have several controls with their own limits, I'd go this way..

Limit_NoCoercion.png

Message 8 of 10
(2,663 Views)

Thanks, works perfectly and is very efficient considering I have many controls with different valid ranges

0 Kudos
Message 9 of 10
(2,610 Views)