To stop an infinite loop, you must abort the VI by clicking the Abort Execution button on the toolbar.
![event structure labview event structure labview](https://image3.slideserve.com/6623383/state-machines-multiple-loops-cont-l.jpg)
To use a control to stop a While Loop, you should place the control terminal inside the loop. Boolean Control Outside the While LoopĬhanging the value of the control does not stop the infinite loop because the value is read only once, and that happens before the loop starts. If the control is FALSE when the loop starts, you cause an infinite loop.įigure 2. If the conditional terminal is Stop if True, you place the terminal of a Boolean control outside a While Loop. Infinite loops are a common programming mistake that involves a loop that never stops. Note: The While Loop always executes at least once. The iteration count for the While Loop always starts at zero. The iteration terminal is an output terminal that contains the number of completed iterations. Also, the Stop if True and Continue if True shortcut menu items change to Stop if Error and Continue while Error. When you wire an error cluster to the conditional terminal, only the True or False value of the status parameter of the error cluster passes to the terminal. You also can perform basic error handling using the conditional terminal of a While Loop.
#Event structure labview code
The While Loop executes the code it contains until the conditional terminal, an input terminal, receives a specific Boolean value. When you release the mouse button, a While Loop boundary encloses the section you selected.Īdd block diagram objects to the While Loop by dragging and dropping them inside the While Loop. Select the While Loop from the palette and then use the cursor to drag a selection rectangle around the section of the block diagram you want to repeat. The While Loop is located on the Structures palette.
![event structure labview event structure labview](https://flylib.com/books/3/352/1/html/2/images/13lve45.jpg)
![event structure labview event structure labview](https://zone.ni.com/images/reference/en-XX/help/371361R-01/loc_bd_eventinsidecase.gif)
(1) LabVIEW While Loop | (2) Flowchart | (3) Pseudo Codeįigure 1 shows a While Loop in LabVIEW, a flowchart equivalent of the While Loop functionality,Īnd a pseudo code example of the functionality of the While Loop. Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop, shown in Figure 1, executes the code it contains until a condition occurs. Video: Creating Loops in LabVIEW While Loops