Programmatically Check If a SubVI Input Terminal Is Wired

Updated Jan 3, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

I have a subVI and its behavior depends on which inputs are wired to it. How can I programmatically check if one of its input terminals is wired?

Solution

You can programmatically check if an input terminal is wired to the subVI by comparing the current value of the input to its default value. You should set the default value of the input to an improbable value. The boolean statement 'Is the input value equal to its default value?' can be used to control the behavior of the subVI.

For example, below is a simple subVI that outputs a string stating whether or not its input is wired. In this example, the subVI Input control is assigned a default value of 999999 because it assumed that the subVI Input will never hold that value. The subVI then compares value of the input with a numeric constant to see if the value of subVI Input is equal to its default value. If the result of this comparison is True, the Output indicator diplays a statement saying the input is not wired. If the result of the comparison is False, the Output indicator displays a statement saying the input is wired.


True Case: Print "Input is not wired" if subVI Input is not wired (i.e. subVI Input is set to the default value of 999999)


False Case: Print "Input is wired" if subVI Input is wired (i.e. subVI Input is not equal to the default value of 999999)

Note: To assign the default value to a control, enter the desired value into the control on the front panel then right-click on the control and select Data Operations>>Make Current Value Default.

Additional Information

An alternative method for checking if an input terminal is wired would be to use VI Scripting. VI Scripting enables you to create, edit, run, and inspect VIs programmatically. A community example of using VI Scripting to create a basic Terminal Checker VI can be found at NI Community: Check for Unwired Terminals Using VI Scripting. For more information about VI Scripting, refer to the Related Links section.

WAS THIS ARTICLE HELPFUL?

Not Helpful