While Loop
- Updated2023-02-17
- 3 minute(s) read
While Loop
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.
Inputs/Outputs
Iteration
Current loop iteration count. The loop count always starts at zero for the first iteration.

Condition
A Boolean input value to determine whether to continue executing the loop.

Tunnel
Point through which data enters or exits a structure.
Tunnels can also assume the following types of functionality:
Keep Last Value—Passes the data through the loop border.
Auto Index Values—
For a single loop iteration, either processes one element of an array if the tunnel is an input or appends a piece of data to an accumulating array if the tunnel is an output. To turn on auto-indexing for a tunnel, right-click the tunnel and select
.
Concatenating—Appends all elements of the input array in order, forming an output array of the same dimension as the input array. This tunnel concatenates arrays in the same way as the Build Array node. You can configure a conditional output for any tunnel type by selecting the tunnel and clicking the Conditional checkbox in the Item tab. When the conditional input for a tunnel is True, the loop writes the corresponding value to the tunnel. When the condition input for the tunnel is False, the loop doesn't write the corresponding value to the tunnel.

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.

Create Shift Register
Adds a pair of shift registers to the loop to pass data from one loop iteration to the next.
Programming Patterns
- Repeating Operations until a Condition Occurs
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.