LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a parameter has been passed to a sub-VI?

Is there a way to programmatically determine whether a parameter has been passed to a sub-VI, i.e. upon execution of that sub-VI it received an input on a particular terminal from the caller?
0 Kudos
Message 1 of 4
(3,746 Views)
It is not clear as to what you're trying to do. If a wire is connected to an input terminal of a subvi then the subvi will not execute until data arrives on that wire. This does not insure, however, that the data which is received is valid data.

If an input terminal on a subvi is left unwired then the subvi will execute with the default value for that control.

If you really need to check to see if the subvi received data then you could set the default to be invalid (for instance, NaN for a numeric control) and then check to see if the input is valid.
0 Kudos
Message 2 of 4
(3,741 Views)
The third item was the intended question, and in fact I had used the method you suggested, but was hoping for something more elegant, e.g. using the property node for the control.

Cheers!
0 Kudos
Message 3 of 4
(3,737 Views)
A control will always have a value. If a subvi control is connected through the connector panel to the main vi then the value will be what is passed from the main vi. Otherwise it will be the default value. If a wire is connected to the subvi then the subvi cannot run until data is received on that wire. This is the point that I was trying to get across before. I don't understand why you would need to determine within the subvi which values are connected.

If you're trying to make a vi which has a fixed set of inputs, but uses some and not others depending on the mode for that particular operation, then why not use a state machine approach. You can use an enumurated value to tell the subvi from the main vi which mode of operation to follow. You can then utilize only those parameters which are necessary for that mode of operation.

If your problem is just in troubleshooting you could put a probe one the controls of interest.
0 Kudos
Message 4 of 4
(3,705 Views)