Data can be passed out of or into a loop through a tunnel. Tunnels feed data into and out of structures. The tunnel appears as a solid block on the border of the loop. The block is the color of the data type wired to the tunnel. Data passes out of a loop after the loop terminates. When a tunnel passes data into a loop, the loop executes only after data arrives at the tunnel. In Figure 4.9, the iteration terminal is connected to a tunnel. The value in the tunnel does not pass to the Iteration Number indicator until the While Loop has finished execution. Only the last value of the iteration terminal displays in the Iteration Number indicator.
Terminals Inside Or Outside Loops
Inputs pass data into a loop at the start of loop execution. Outputs pass data out of a loop only after the loop completes all iterations. If you want the loop to check the value of a terminal for each iteration, place the terminal inside the loop. When you place the terminal of a front panel Boolean control inside a While Loop and wire the terminal to the conditional terminal of the loop, the loop checks the value of the terminal for every iteration to determine if it must iterate. You can stop the While Loop as shown in Figure 4.10(a) by changing the value of the front panel control to FALSE.
Subscribe to our youtube channel to get new updates..!
If you place the terminal of the Boolean control outside the While Loop as shown in Figure 4.8(b), and the control is set to FALSE if the conditional terminal is Stop if True when the loop starts, you cause an infinite loop. You also cause an infinite loop if the control outside the loop is set to TRUE and the conditional terminal is Continue if True. Changing the value of the control does not stop the infinite loop because the value is only read once, before the loop starts. To stop an infinite loop, you must abort the VI by clicking the Abort Execution button on the toolbar.