Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated

Stopping Nested While Loops with One Button



Primary Software: LabVIEW Development Systems>>LabVIEW Full Development System
Primary Software Version: 7.1
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Development Systems

Problem:
I am using nested While Loops and want to be able to stop both loops with a Stop button. When I press the Stop button, I don't want the code in the outer While Loop to execute.

Solution:
There are several solutions to this problem depending upon the applications needs. In all applications, you will need to use a Case Structure in the outer While Loop. Connect the Stop button in the inner While Loop to the case selection terminal of the Case Structure in the outer While Loop. However, the following VI Snippet (Figure 1) shows one way to do this. In this example, it is assumed that the application requires the outer While Loop to execute occasionally, but not on the iteration after the Stop button was pressed.

Figure 1: Stopping nested While Loops using one stop button.



Related Links:
KnowledgeBase 3GGDIMTY: Stopping Parallel While Loops in LabVIEW With One Stop Button 
Developer Zone Example Code: Stopping Two While Loops with One Switch Control

Attachments:
NestedLoop.vi




Report Date: 08/30/2000
Last Updated: 10/05/2017
Document ID: 20T96QLJ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit