LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ending a while loop inside a while loop

How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way?
 
Thanks.
0 Kudos
Message 1 of 3
(2,673 Views)
It doesn't work because of data dependency. Once you are inside the inner loop the outer loop will not go to the next iteration until the inner loop is done. It sounds to me like you want parallel loops running, rather than one inside the other.

If you open the Example Finder (Help -> Find Examples), and search for "loops", open the examples called "Stopping Parallel While Loops". One has a reset, and one doesn't.


Message Edited by smercurio_fc on 04-22-2008 04:55 PM
0 Kudos
Message 2 of 3
(2,669 Views)
Hi Jasonalan,

I am not sure what you are trying to implement, but it is true that the loops are not terminating because of data dependency. The stop button in the outer loop will not be read until the inner loop terminates.

If you wish to terminate the two nested loops using a single stop button, you should read the stop button inside the inner loop and wire it to the conditional terminals in both the inner and outer loop. Again, there is no point in doing this unless you have some other logic along with the stop button to stop the loops. If only the stop button is being used to stop both the inner and outer loops, the outer loop will only execute once. In that case, you can just use a sequence structure followed by a single while loop.
0 Kudos
Message 3 of 3
(2,658 Views)