Example Code

Programmatically Check if a SubVI Input Terminal is Wired

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

Coding that exemplifies how to verify if a SubVI's input is not wired.

 

Description

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 will have to set the default value of the input to an improbable value. The Boolean (Is input value default?) can be used to control the behavior of the sub VI.

In the example below, we want to add two numbers together only if the x input is wired. If x is wired, it will compute x+y. If x is not wired, the VI will pass y through to the output. In this example, the x control has been assigned the number 999999 as default; and it is assumed that x will never hold that value.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Create a Blank VI.
2. Add the "Add If Input Wired LV12 - NI Verified.vi" to the block diagram and wire the terminals.
3. Specify a random value to the input X.
4. Disconnect this input and run the VI again.


Additional Information or References

Snippet.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Gyc
Member
Member
on

Could someone please convert the vi to LV8.6.1???