LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

close more than one while loop with one button?

Hello, I need some help with while loops and sequences. I have 3sequences, and each includes at least one while loop. And I'd like to stop each while loop with the same button.  besides this, If I pushed this bttton, I'd like to start in sequence 0 again. maybe it would work with events - what do you think?

 

Thanx for ya help

0 Kudos
Message 1 of 5
(2,859 Views)

You can use local variables to stop any separate loops you want with a single button. Right-click on a button and select Create -> Local variable. Then deploy it in the desirable loop and wire its output to the conditional terminal of the loop.

 

Edit: Just don't overuse the locals while programming.

Message Edited by Giedrius.S on 02-11-2010 03:48 PM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
Message 2 of 5
(2,849 Views)
Events would work for that situation. You can also use queuing. There are many different ways to do this and everyone has their favorite. If you post your code we can offer some suggestions.
Tim
GHSP
Message 3 of 5
(2,848 Views)

The advice you have received will get you out of the while loops, but the remainder of the sequence(s) will execute to completion before anything else can happen.  To restart a sequence you would need to enclose it in another while loop.

 

What your description implies is that it will be very difficult for you to get the program to work the way you want it to with the methods you are using.  A much better way would be to switch to a state machine architecture.  The minimum implementation is a while loop enclosing a case structure.   Each case represents a state. The case selector is wired to a shift register to pass the next state selection from one iteration to the next.  There are many examples which come with LV and lots of posts on the Forums about state machines.

 

Lynn 

Message 4 of 5
(2,839 Views)
Posting your code will be the quickest way for you to ge tthe exact help that you are requesting.
Tim
GHSP
0 Kudos
Message 5 of 5
(2,833 Views)