Example Code

Count the Number of Controls, Indicators, and Nodes in a VI in LabVIEW

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

Overview

Some developers are interested in the number of Controls or Indicators on a Front Panel or the number of Nodes on a Block Diagram. This is a good way of measuring code complexity. This example illustrates the properties that can be used to get these counts.

 

Description

This VI uses Front Panel property Controls[] and the Block Diagram property Nodes[] to get references to all respective items in an array. The size of this array returns the count of the respective items. In the case of Nodes on the Block Diagram, a Loop or Structure along with any code inside of it will be counted as a single Node. To account for all of the Nodes inside of a Loop or Structure this VI implements an algorithm to find all Nodes on all Diagrams of a Loop or Structure. Notes are included explaining how to account for nested Loops or Structures.

 

Requirements

  • LabVIEW 2013 (or compatible).

 

Steps to Implement or Execute Code

  1. Download the VI
  2. Open the VI
  3. Choose the path of a VI you would like to get a count for
  4. Run the VI

  

Additional Information or References

 

number.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Cameron T
Applications Engineer
National Instruments

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