LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to return control to parent VI

What I want to do is monitor an Abort button and when it goes true I want to stop/close the current VI and return control to the parent VI.  I tried using an Application Stop function, but this stops the entire execution and I only want to stop the current VI.

 

So how can I stop the current VI and turn control back to the parent VI without stopping execution?

 

Screenshot of the VI that dosn't work is attached. 

 

Thanks in advance.

0 Kudos
Message 1 of 6
(3,522 Views)

A semaphore would work nicely for this. 

 

eric

Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 2 of 6
(3,510 Views)
Hi dubs,

As far as turning control over to your parent vi that occurs naturally in Labview so normally there really isn't much you have to do there.  Now to the abort there are different ways to do this. One way is to use the "Open VI Reference" in your "Application Control" menu and wire that into an "invoke node" (in the same menu). The invoke node has "Abort VI" as a function.

This is a bit brute force but it is similar to what you were trying to do in your attachment.

I would look at enclosing your sub vi within a while loop and have 2 conditions that stop the loop (and by extension stop your vi) that you OR together. One being the normal exit strategy and the other being the "abort". Then you can do any cleanup necessary after the loop exits and also inform your top level vi (pass the abort state up) that the user aborted the operation of the sub vi before natural completion (almost always useful information to your program).

hope this helps

Cheers,

--Russ


Message 3 of 6
(3,495 Views)
Hi All,
 
I did something similar to allow the user to restart the Main Screen.vi from the vi itself. Take a look!
 
If you see a way to do this more elegantly, Please share...
 
 
0 Kudos
Message 4 of 6
(3,483 Views)
Dubs,

I second Russ's thoughts that "aborting" a VI is a "bit brute force" and generally not a good programming practice.

I would suggest using while loops coupled with the Elapsed Time VI to create an interruptible wait function similar to what is in the following screenshot:



I hope this helps,

Simon H
Applications Engineer
National Instruments

Message Edited by Simon H on 11-16-2006 03:14 PM

0 Kudos
Message 5 of 6
(3,437 Views)
Thats perfect!  Thanks for the help guys.
0 Kudos
Message 6 of 6
(3,431 Views)