Comment Out or Disable Pieces of Code in LabVIEW

Updated Aug 18, 2023

Reported In

Software

  • LabVIEW Base
  • LabVIEW Base (Legacy)

Issue Details

I want to be able to comment out pieces of my code in LabVIEW like I can in other programming languages, such as C. Can I gray out certain functions so they don't execute?

Solution

LabVIEW 2009 and later
Commenting out code depending on some user-defined condition is a native part of LabVIEW 2009 and later. The Conditional Disable Structure is used to accomplish this. This structure is in addition to the Diagram Disable Structure introduced in LabVIEW 8.x. 

LabVIEW 8.x 
Commenting out code is a native part of LabVIEW 8.x and later. The Diagram Disable Structure is used to comment out code.

LabVIEW 7.1.1 and earlier
There is no option to comment out code. Instead, you can place a Case Structure around the nodes you want to disable. The nodes you want to disable are in the True case of the structure, so wire a FALSE Boolean constant to the selector terminal. If the Case Structure produces any data values, switch to the False case and either wire the input tunnel to the output tunnel or right-click the output tunnel and select Create»Constant from the shortcut menu. To execute the code you disabled, change the Boolean constant to TRUE by right-clicking it and selecting Data Operations»Change Value to True.