Table Of Contents

While Loop (G Dataflow)

Version:
    Last Modified: March 15, 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.

    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 Append Mode»Auto Index Values.
    • 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.

    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.

    Use Search to find and open the following installed lesson: While Loops

    Use Search to find and open the following installed examples:
    • Simple While Loop
    • State Machine Fundamentals

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics