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.
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.
05-21-2014 05:20 AM
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 replies
05-21-2014 06:32 AM
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.
05-21-2014 07:38 AM
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.
05-21-2014 07:59 AM
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