From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to break out of subvi

Hi,

 

In my program, I want to leave a Vi, incorporated within a Vi when a certain condition is set to true.

 

How can I jump out of the vi in use.

 

thanks

 

Kudos for most gracious repliesSmiley Happy

0 Kudos
Message 1 of 4
(2,593 Views)

Force stopping a VI (or subVI for that matter) is rarely recommended.

 

If you provide a little more information about the VIs, we could probably give you a more specific example.  If its something like a loop inside the subVI, then you could use a global variable/shared variable/functional global.  Then you can simply trigger it to exit whenever something in the top level VI triggers.

 

Another option is if the subVI is a queued message handler or state machine is to have a "break" case or message that when signaled will cause the subVI to quickly clean up and exit.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 4
(2,576 Views)

This normally points to a bad architecture.  We would have to see code to say for sure.  It really depends what your subVI is doing and why it is running off on its own.

 

In my code, I normally and sending commands to a subVI via a queue.  One of those commands is the stop command.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(2,558 Views)

Although crossrulz is probably correct. A quick fix would be to use a case structure but BE CAREFUL here. If you'll over-use this option a big risk is that you'll run in the types of VI you shouldn't (spaghetti code).

 

If you have access to the training material form core 1 (you have this if you have a service contract) take a look at these courses:

2012_LV1M35: Understanding State Programming

2012_LV1M36: Using State Machines

0 Kudos
Message 4 of 4
(2,549 Views)