LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coercing Values within SubVIs

Good morning,

 

If I were to edit the acceptable values of the input of a subVI (the control within the VI itself with coerce as the response to value outside limits), then the subVI received a value outside of those, would it correct it or error out?

 

Example: SubVI control is limited to input value of 100 but the control in the main VI inputs 110. Would the subVI correct it, input 110, or error out?

 

Thanks,

 

Anthony

0 Kudos
Message 1 of 6
(3,145 Views)

The simplest thing to do is "Play Scientist" -- do the Experiment.  Write such a sub-VI, call it with an "out of range" parameter, and see what value you get.  What I expect to happen (I haven't done the experiment) would be that the Control that you've coerced to be, say, 0 .. 100 will simply return the Coerced value (e.g. 100) and no error.

 

Try it yourself, and post the Solution to your own problem ...  Maybe you'll prove me to be wrong!

 

Bob Schor

0 Kudos
Message 2 of 6
(3,129 Views)

@Bob_Schor wrote:

The simplest thing to do is "Play Scientist" -- do the Experiment.  Write such a sub-VI, call it with an "out of range" parameter, and see what value you get.  What I expect to happen (I haven't done the experiment) would be that the Control that you've coerced to be, say, 0 .. 100 will simply return the Coerced value (e.g. 100) and no error.

 


I have not done the experiment either, but I think this was correct in ancient LabVIEW, but this is no longer the case. The input will not be coerced.  The subVI will operate on a value of 110 and not generate an error.

 

Now go do the experiment! 😄

0 Kudos
Message 3 of 6
(3,095 Views)

Data entry range is only applied as the user is inputting the data (directly in to the control).  You can still get values out of the entry range via local variables and passing the value into subVI.


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 4 of 6
(3,074 Views)

And the workaround is:

Example_VI_BD.png

NOTE: The code dependant on "In Range?" is entirely optional Smiley Wink  It is there simply as an example of a potential debug feature so you can use the call chain ring to find the offending caller.  Then you know who to blame for writing code that passed in bad values to your viSmiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 6
(3,062 Views)

Finished a test and was able to try it out. As pointed to, the coersion does not stop the values from being entered into subVIs. I will probably end up just writing failsafes into the subVIs in case something is outside of range (thank goodness for that function).

 

Thank you everyone,

 

Anthony

0 Kudos
Message 6 of 6
(3,033 Views)