LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop a 'while' loop of subVI, which inside main program's 'while' loop

Hi all,

 

I've been searching on forums the answer to the problem of stoping a while loop inside a subVI, which in turn inside a main program's while loop. I know some of you might say, but why would you want that, why don't you have either a parallel loop or make the use of the main while loop instead of the while loop in subVI. I agree with this reasoning, however, I still want to know if such thing possible.

 

Thanks in advance.

 

Viktar 

0 Kudos
Message 1 of 4
(4,088 Views)

You have a lot of options. You could use a functional global stop, a shared variable (if you have them) "all stop", or a stop using a notifier.

PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 2 of 4
(4,086 Views)

Are shared variables commonly used to stop a program across all VIs? With most of our LabVIEW programs at my work, if you click the exit button it will sometimes take a minute or two to get the program to stop while the current SubVI(s) finish up their work. That's not always desirable behavior... Would stopping the loops in these SubVIs with a "All Stop" shared variable be the way to do that? It seems like it is suggested that they are in the last post, but I just had to ask the specific question! 

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

Hey zenthoef,

 

Like PaulG said, there are a few ways to accomplish this goal.  Shared variables are a good option, and should complete the task at hand.  Each subvi can read from from that shared variable and will know to stop as soon as it is changed.  All you have to do is switch the variable on the main vi, and the subvi's will stop, assuming they are finishing their loops.

 

Regards,

Jake

Regards,
Jake G.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(4,040 Views)