LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop a while loop when using tab control

How do you use a tab contol to stop what is happening on one tab when you switch to another tab?  In the test example I attached, I have a while loop nested inside a case structure controlled by the tab control.  When I tab to page two the elapsed timer starts but when I switch to another tab it does not stop.  I can't come up with an easy way to stop or exit the while loop when I change tabs. 

 

Thank you

 

 

Danny
0 Kudos
Message 1 of 4
(3,531 Views)

I played with it a little more and came up with this fix.  This fixes it but is not tied to the changing tabs as I was looking for.  Is this just too many nested loops and a bad idea?

Danny
0 Kudos
Message 2 of 4
(3,521 Views)

Once you are inside the nested loop you cannot see changes in the value of the tab unless you use a local variable of the tab control, as you are currently doing with the Stop button. So, a simple fix than what you have is to simply use a local variable (those who hate local variables, please pipe down for now) of the tab control and to compare it to see if it's not equal to page 2.

 

What exactly are you trying to accomplish.

 

Also be aware that unless you are performing something that really needs to execute as fast as possible, your loop should have a small delay to prevent it being a Greedy Loop.

0 Kudos
Message 3 of 4
(3,510 Views)

Thank you for the help Smercurio.  Your help is what I sort of figured out this morning but it was very helpful to know I wasn't missing something.

 

Thanks again.

 

 

Danny
0 Kudos
Message 4 of 4
(3,490 Views)