STRUCTURES IN LABVIEW
Structures are graphical representations of the loops and case statements of text-based programming languages. There are cases when a decision must be made in a program. In text-based programs, this can be accomplished with statements like if-else, case and so on. LabVIEW includes many different ways of making decisions. The simplest of these methods is the select function located in the functions palette. This function selects between two values dependent on a Boolean input.
Use structures on the block diagram to repeat blocks of code and to execute code conditionally or in a specific order. Like other nodes, structures have terminals that connect them to other block diagram nodes, execute automatically when input data are available, and supply data to output wires when execution is complete. Each structure has a distinctive, resizable border to enclose the section of the block diagram that executes according to the rules of the structure. The section of the block diagram inside the structure border is called a subdiagram. The terminals that feed data into and out of structures are called tunnels. A tunnel is a connection point on a structure border.
Use the following structures located on the Structures palette to control how a block diagram executes processes:
- For Loop—Executes a subdiagram a set number of times.
- While Loop—Executes a subdiagram until a condition occurs.
- Case structure—Contains multiple subdiagrams, only one of which executes depending on the input value passed to the structure.
- Sequence structure—Contains one or more subdiagrams that execute in sequential order.
- Event structure—Contains one or more subdiagrams that execute depending on how the user interacts with the VI.
- Timed Structures—Execute one or more subdiagrams with time bounds and delays.
- Diagram Disable Structure—Has one or more subdiagrams, or cases, of which only the enabled subdiagram executes.
- Conditional Disable Structure—Has one or more subdiagrams, or cases, exactly one of which LabVIEW uses for the duration of execution, depending on the configuration.