LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a while loop BEFORE it re-executes

Hi!,

When using While loops I have found that the loop executes ONE time AFTER I have hit the stop button before it terminates.

How can I avoid this? I want the loop to complete the present iteration and stop.

Thanks!

- Gurdas
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 1 of 3
(2,457 Views)
Labview occassionally has limitations as compared to C or Basic languages, such as limited case structuring. While loops check the status of the Condition at the start of the loop, then run the loop. If the condition was met, the next iteration does not execute. You can bypass it by having a secondary check on the Condition within the loop and using a case structure, such as in the example attached.


2006 Ultimate LabVIEW G-eek.

0 Kudos
Message 2 of 3
(2,457 Views)
I suspect the problem has to do with the dataflow nature of the LabVIEW block diagram. What happens when LabVIEW executes code code in a loop is that all controls that can be read are read(like the stop button). After the controls are read, the data is then passed to the next part of the program. If the continue if true or stop if true is connected directly to the stop button, the the loop is set to iterate or not iterate again. You might consider putting the stop button in a sequence struture and running a wire from the end of the code you want to execute (like the error cluster)to the edge of the sequence structure. This way the stop button is read after all the code in the loop has executed.
0 Kudos
Message 3 of 3
(2,457 Views)