Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Conditional Disable and Diagram Disable Structures

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

A disable structure contains multiple subdiagrams of which exactly one compiles and executes. Code within the inactive subdiagrams does not compile or execute at run time. You can use disable structures to make sections of code on the block diagram inactive.

When LabVIEW loads a VI with user-defined objects, such as subVIs and type definitions, in the Disabled subdiagram of a Diagram Disable structure or in the inactive subdiagrams of a Conditional Disable structure, LabVIEW does not load these objects into memory. However, when you display the block diagram of the VI, if LabVIEW cannot find the objects, the missing objects appear with a question mark icon. The VI does not break because LabVIEW does not include the code when compiling and executing the VI.

Note  LabVIEW checks the syntax of code in inactive subdiagrams. However, broken code within the inactive subdiagrams does not prevent the VI from compiling and executing.

Use the Diagram Disable structure to disable specific code on the block diagram. Use the Conditional Disable structure to define conditions that indicate which code on the block diagram executes.

Conditional Disable Structure

The Conditional Disable structure, shown as follows, has one or more subdiagrams, or cases, exactly one of which LabVIEW uses for the duration of execution, depending on the configuration of the conditions of the subdiagram. When compiling, LabVIEW does not include any code in the inactive subdiagrams of the Conditional Disable structure.

Use the Conditional Disable structure to define conditions in which specific code compiles and executes. For example, if one section of a VI is target-specific, you can put this code in a Conditional Disable structure and configure it to run on the specific target. You might configure a Conditional Disable structure for Windows, Mac, Unix systems or FPGA targets.

Creating Conditional Disable Symbols

You can use conditional disable symbols in the case selector of the Conditional Disable structure to indicate to LabVIEW when cases of the structure should execute. Conditional disable symbols consist of a symbol name and a symbol value. Comparing the symbol name and the symbol value creates a condition that must be TRUE for LabVIEW to compile and execute the subdiagram. You can join conditions through Boolean operators to create an expression that allows LabVIEW to evaluate multiple conditions. If more than one condition evaluates to TRUE, the first condition that evaluates to TRUE determines the active subdiagram for the structure.

Use the Conditional Disable structure in a LabVIEW project to increase the functionality of the structure. Using the Conditional Disable structure in a VI allows you to execute target-specific code on the block diagram. If the Conditional Disable structure is not in a LabVIEW project, targets are not available for you to use. You can create conditional disable symbols at the project level in the Project Properties dialog box. You also can create conditional disable symbols at the target level in the appropriate Target Properties dialog box. For example, if you are using an FPGA target, you can create the conditional disable symbol in the FPGA Target Properties dialog box.

Note  If you do not use the Conditional Disable structure in a LabVIEW project, TARGET_TYPE is the only symbol available. You can use the TARGET_TYPE symbol to establish on which platforms or which targets the subdiagram executes. The valid values for the TARGET_TYPE symbol include Windows, FPGA, Embedded, RT, Mac, Linux, and PocketPC.

If you define a Boolean expression for a subdiagram on the Conditional Disable Symbols page, the symbol/value comparisons that you join through the AND operator are evaluated before symbol/value comparisons you join with the OR operator.

If the same symbol is defined on both a project level and a target level in the same project, the Conditional Disable structure recognizes only the symbol defined for the target.

If you want to disable a section of code on the block diagram so that it does not compile at run time, use the Diagram Disable structure. To convert a Conditional Disable structure to a Diagram Disable structure, right-click the border of the Conditional Disable structure and select Change To Diagram Disable Structure from the shortcut menu.

Note  If you convert from a Conditional Disable structure to a Diagram Disable structure, the conditions of the Conditional Disable structure do not transfer to the Diagram Disable structure.

Refer to the Conditional Disable Structure project in the labview\examples\general\disable structures\ for an example of using Conditional Disable structures. 

Diagram Disable Structure

In the Diagram Disable structure, shown as follows, LabVIEW does not include any code in the Disabled subdiagrams when compiling.

Use the Diagram Disable structure if you want to disable specific code on the block diagram. For example, you can use the Diagram Disable structure as a debugging tool to comment out code, replace code, and compile a VI without deleting the code in the Disabled subdiagram of the structure.

If you want to enable a section of code only when certain conditions are met, use the Conditional Disable structure. To convert a Diagram Disable structure to a Conditional Disable structure, right-click the border of the Diagram Disable structure and select Change to Conditional Disable Structure from the shortcut menu.

Refer to the Diagram Disable VI in the labview\examples\general\disable structures\Diagram Disable Structure.vi directory for an example of using Diagram Disable structures.  


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit