Table Of Contents

While Loop (G Dataflow)

Last Modified: January 9, 2017

Repeats the code on its subdiagram until a specific condition occurs. A While Loop always executes at least one time. A While Loop behaves similarly to a do while loop in other programming languages.

Programming Patterns
terminal_icon

Iteration

Current loop iteration count. The loop count always starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1, the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater integer range.

terminal_icon

Condition

A Boolean input value to determine whether to continue executing the loop. To specify whether the loop stops for a TRUE or FALSE Boolean value, configure the continuation behavior. You also can determine when the loop stops by wiring an error cluster to the condition terminal.

terminal_icon

Tunnel

Point through which data enters or exits a structure.

In addition to this basic purpose, tunnels can assume the following types of functionality:

  • Non-indexing tunnel—Passes the data through the loop border.
  • Auto-indexing The behavior of an auto-indexing tunnel depends on whether it is an input or output tunnel. An auto-indexing input tunnel processes one element of an array for each iteration of the loop. An auto-indexing output tunnel appends a piece of data from a single loop iteration to an accumulating array of data. To turn on auto-indexing for a tunnel, right-click the tunnel and select Auto Index Values.
terminal_icon

Shift Register

Member of a pair of terminals that passes a value from one iteration of a loop to the next iteration. After the initial loop iteration, the left shift register in the pair returns the value it receives from the right shift register from the previous iteration.

Refer to Accessing Data from the Previous Loop Iteration for more information about passing values from the previous iteration to the current iteration.

Controlling Loop Timing

Refer to Loop Timing for more information about controlling the execution speed of a loop.

Accessing Data from the Previous Loop Iteration

Refer to Accessing Data from the Previous Loop Iteration for more information about passing values from the previous iteration to the current iteration.

Search LabVIEW for the following installed lesson: While Loops

Where This Node Can Run:

Desktop OS: Windows

FPGA: All devices (only within an Optimized FPGA VI)


Recently Viewed Topics