10-26-2019 12:12 PM
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
Solved! Go to Solution.
10-26-2019 12:20 PM
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.
10-28-2019 08:44 AM
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.
10-28-2019 10:36 AM
@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?
10-28-2019 11:01 AM
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.
10-28-2019 11:14 AM
@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.
10-28-2019 11:17 AM
@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).
10-28-2019 11:23 AM
I thought this would be even better.
If you have several controls with their own limits, I'd go this way..
10-29-2019 09:56 AM
Thanks, works perfectly and is very efficient considering I have many controls with different valid ranges
10-30-2019 09:39 AM
Also we could vote for that idea.
https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Provide-a-Value-Change-Filter-event/idi-p/3035343