LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data range of local variable does not match original control.

My controls are set with a max and min in the data range, and set to coerce if out of range. Yet when I write to the control's local variable, the control value goes out of range.
0 Kudos
Message 1 of 8
(3,311 Views)
Hi Peg,

LabVIEW generates two data aeras for each control or indicator. One aera is for the code, the other is for the front panel. You reach the code area by using a local variable and the front panel area by using the property node "value".
Writting to the local variable will never go through the LV code which makes the range checking, so it is possible to write values to a local variable which is out of range.
Also you have to consider if you use a control in the connector pane, range checking will not done if you call this VI as a subVI. This behaviour has been changed from LV 5 to LV 6 generating a lot of warnings when converting from LV 5 to LV 6.
There are some articles from Greg McKaskle in this forum about local variables and property nod
es and it is explained there in detail.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 8
(3,311 Views)
For programatically range checking and coercion, there is the In Range and Coerce function on the Comparison palette.
0 Kudos
Message 3 of 8
(3,311 Views)
This works.
Thanks, Peg
0 Kudos
Message 4 of 8
(3,311 Views)
The coerecion of the range , max & min, works only and is intended only for user interface.
Programatically, if one passes data to a local variable or its value (from a property node, it will not coerce the input)
0 Kudos
Message 5 of 8
(3,311 Views)
Dr. Imad, I guess I don't know what you mean. If I place the "In Range&Coerce" before my local variable, it seems to be succesfully forcing the control to stay within the specified range.
Peg
0 Kudos
Message 6 of 8
(3,311 Views)
If one place the "In Range&Coerce" function before a local variable, it forces the control to stay within the specified range, as expected.

However, if the "In Range&Coerce" is not used, the local variable will accept data passed to it programmatically outside the range specified in its properties in the front panel. This behavior is correct for version 6i and above. For earlier versions (5.1, 5.0, 4.1 ), the control will take a coereced value of the data.


But if a user tries to enter a value outside the max and min range (from the front panel), the control will coerce the value to the nearest limit even if the "In Range&Coerce" function is not used (for all versions of LabView"
0 Kudos
Message 7 of 8
(3,311 Views)
Yes, ok. That is what I've been observing and I have to be more careful about how I use local variables. Thanks for your comments.
Peg
0 Kudos
Message 8 of 8
(3,311 Views)