LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exiting a While Loop

Solved!
Go to solution

Hello,

 

I have a while loop which I want to exit by a stop on the front panel.

 

Here is bit of code:

 

Capture.JPG

 

As you can see the code in the while loop is processed by completing four sub .vi.

 

I have found that if I press the stop button at a point when computing any of the 4 sub .vis then the while loop will make another pass and not exit at the end of the computation of the 4 sub .vis.

 

What is the way around this please? I realise that using stops on the front panel is not advisable!!!!

 

Thanks,

 

Daniel

0 Kudos
Message 1 of 7
(2,801 Views)

Hi nevica,

 

you need to THINK DATAFLOW!

 

When you press the STOP button while the loop is executing the 4 subVIs it needs (most probably) another iteration to read that button once again!

 

Solution:

Read the button after your subVIs has been called. Use a (flat) sequence to do so…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,799 Views)

Yes,  I am sorry. I understand what you mean regarding the timing of the loop and when the stop is read. But the stop in the while loop has to stay in the while loop. It cannot be put in a flat structure so thet the stp is read afterwards.

 

If I create a flat sequence (with two sequences) and the final sequence having a stop, How do repeat a flat sequence without using a while loop?

 

I could use a case structure. Case 1 being the while loop (so that it repeats and Case 2 empty. the question remains when is the case selector read for the case structure?

 

Daniel

0 Kudos
Message 3 of 7
(2,787 Views)

The flat sequence structure goes inside the while loop.

 

Case structure would work fine in this case, also.  I like that solution better.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 7
(2,781 Views)
Solution
Accepted by nevica

Done

 

 

 

Capture.JPG

0 Kudos
Message 5 of 7
(2,774 Views)

Put something like this...

Flat.png

 

... here

Omar
0 Kudos
Message 6 of 7
(2,769 Views)

Hi nevica,

 

the posts before your own solutions post, states the same. IMHO, it is more fair to give one of them the "medal of solution". 

0 Kudos
Message 7 of 7
(2,722 Views)