LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

exit from a while loop in sub vi

Main vi has several sub-vi's. Each sub vi has a while loop and Boolean button. When program runs, sub-vi front panel appears, and I can stop/continue the while loop. But when I stopped a while loop in a sub-vi, I cannot control other while loops in other sub vi.
I need exit function from a while loop, not stop function of entire program.
Thanks.
0 Kudos
Message 1 of 4
(3,079 Views)
Hi,

One solution would be to use a Global Variable so that the other subVI could read this to get the current state of the loop or would write to it to signal terminating a loop.

If you what to be a bit more adventuous. You could use a message queue that is common to the main and subVI's. You can find an example of message queuing the the LabVIEW examples under VI Execution Control.

Hope this helps
Ray Farmer
Regards
Ray Farmer
Message 2 of 4
(3,079 Views)
Instead of having the while loop in the subVI, take it out, and place the button in the front panel. Make your subVI-s do they work only once and have the while loop out of them.
Hope this helps
0 Kudos
Message 3 of 4
(3,079 Views)
Hallo,

Can the use of occurrences solve this problem?

The Main program can create an occurrence which can be passed to the
sub-VIs. Upon pressing the button to cancel the loop, the occurrence can be
set, instantly transmitted to all other VIs sharing which were passed the
same occurrence. Of course a small handling routine has to be written (say
a sequence parallel to the executing while loop waiting for the occurrence
and then setting the exit parameter to "true") but this is trivial.

I have checked this with a small program splitting an occurrence to three
seperate VIs and it works.

If you want, I can send a copy of it.

It may well be possible with notifiers or something else, but I have far
less experience with them.

Hope this helps

Shane

pcu schrieb in Nachr
icht
<506500000008000000A7200000-991728092000@quiq.com>...
>Main vi has several sub-vi's. Each sub vi has a while loop and Boolean
>button. When program runs, sub-vi front panel appears, and I can
>stop/continue the while loop. But when I stopped a while loop in a
>sub-vi, I cannot control other while loops in other sub vi.
>I need exit function from a while loop, not stop function of entire
>program.
>Thanks.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 4
(3,079 Views)