LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close existing VI and open another VI simultaneously

Solved!
Go to solution

Hello,

When the user presses a button in the front panel, I want it to close the existing VI and open another VI.
What I did is presented in the attached picture :
vi.jpg
The problem is that sometimes it closes the existing VI and not opening the other VI.
I've done this exact thing in other VIs without any issue, which leads me to think if this is a problem related to the VI properties maybe?
Note: If I put this code in sequence (Open other vi then close this VI), it only opens the other VI and not closing the existing one (because the other VI has a loop?)

Thank you.

0 Kudos
Message 1 of 22
(2,830 Views)

There are several reasons why this is not a good way to do this, but I'll address the Fundamental Problem -- do you know the Principle of Data Flow, the "central idea" that governs how LabVIEW executes its routines?  [I'm guessing the answer is "No"].

 

Look at your Block Diagram.  Which will be executed first?

  1. The unnamed VI with "2" on the icon's lower right corner.
  2. The Invoke Node closing this VI.
  3. Impossible to predict, even from execution to execution.

Did you choose #1?

 

Bob Schor

0 Kudos
Message 2 of 22
(2,826 Views)

I think the answer is 3 because they are running in parallel .
But then again, I never had a problem with the exact same code, which is weird.

0 Kudos
Message 3 of 22
(2,811 Views)

Search the help for Asynchronous Call and Forget. Basically you call a VI and don't worry about retrieving its response. Do that, then close your calling VI. Should work.

 

mcduff

0 Kudos
Message 4 of 22
(2,806 Views)

Is the calling VI the toplevel VI?

0 Kudos
Message 5 of 22
(2,789 Views)

Yes, #3 is correct, and you seem to have fallen afoul of it.  Does Unnamed VI use the Error Line, i.e. is there an Error Out on its lower-right corner?  [There should be!].  Drag that Error to the Error In of the Invoke node and Data Flow will ensure that they work in the "expected" (and desired) order.

 

Bob Schor

0 Kudos
Message 6 of 22
(2,784 Views)

Yes it is the toplevel VI.

0 Kudos
Message 7 of 22
(2,784 Views)

Hi Bob,

I'm sorry I don't see an error out on the Unnamed VI (the one with the 2) . It doesn't have any inputs or outputs.
Edit : I created an "error out" indicator in the Unnamed VI as the output of the VI and connected it as instructed, the main vi doesn't close.

0 Kudos
Message 8 of 22
(2,778 Views)

@BG1995 wrote:

Yes it is the toplevel VI.


I thought if the toplevel closes, all dependecies will stop executing too. (Not 100% sure). For workarounds search for "splash screen" implementations.

0 Kudos
Message 9 of 22
(2,773 Views)

I have the option "Close afterwards if originally closed" turned off.
Also It doesn't close the existing VI and not opening the other VI all the time, only sometimes.

0 Kudos
Message 10 of 22
(2,768 Views)