LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop while loop from looping

Hi, need a little help in the respect to while loops. Basically i have a while loop within an while loop within another while. So what i want to do is run the program within the outer while loop. The problem is that when i start the program it runs once, which is ok, but its the runs again and again and again. I need it to only run once untill i press the inner while loop bolean to set it going and to stop and to restart, but i can not manage to keep the inner loop from initerating. I just wonder if its a problem with the field point? because i know it works, but using a different example. Any help greatly appreciated.

Thanks Stuart
0 Kudos
Message 1 of 3
(2,767 Views)
Use case structures around your middle and inner loops tied to the booleans you want to control the loops. Inside each loop, use a local variable of the boolean tied to the continue terminal of the loop.

You need to use local variables because an input to a loop (wired from outside the loop) is read only on the first loop iteration. Any subsequent change to a control terminal outside of the loop is not seen by the loop.

To create a local variable, on the diagram, right click on the terminal of interest, then select Create >> Local Variable. Then right click on the local variable and select Change to Read.

P.S. You know your stop button is wired to an empty case and doesn't do anything.
Message 2 of 3
(2,767 Views)
Hi, thanks i understand it a lot better now. yeah! the empty case use to have a txt file save in it. but i just wanted to test it first before adding save as file and save as txt system. I presume if i put some kind of file saving system within this part of the program. i should also contain this within the case structures, so i can call saving when ever i want for recording data.

Thanks Stuart
0 Kudos
Message 3 of 3
(2,767 Views)