LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running VI from another VI

HI,
I have program1.vi running. When a user clicks on a button, Program2.vi needs to be launched. The way I am doing it now, is by calling Program2 in Program1; so program2 acts as a subVI. But I have a problem here..I dont want my Program1 to be running, when Program2 is called. Also, if i abort Program2, Program1 aborts too.
Is there an easy way of running Program2 independent of Program1, though Program1 calls it? I mean aborting Program2 should not cause Program1 to abort and viceversa.
Please reply asap.
Thanks.
0 Kudos
Message 1 of 10
(3,477 Views)
Hi,
Do you mean something like this. Program2.vi can be launched from program1.vi. If you stop program1.vi, it doesn't stop Program2.vi. If you stop Program2.vi, it doesn't stop Program1.vi.

Hope this helps !
Julien
Download All
Message 2 of 10
(3,477 Views)
Shreesha,
Julien's example will run Program2 independent from Program1. Program2 has to be open, though.
I also wanted to add that if you have LabVIEW 6.1 or later, you can take advantage of the event structure, and not have to poll for user clicking on the Boolean button.
I modified the example to use the event structure, and to actually open Program2 front panel when the button is selected.

Zvezdana S.
National Instruments
Download All
0 Kudos
Message 3 of 10
(3,477 Views)
Thanks a lot,
I have a question...will this work if I create a exe file of Program1 and run the exe??
0 Kudos
Message 4 of 10
(3,477 Views)
Hi Zvezdana,
I am having some doubts about Event structure.
I have a program in which there is a 'while loop' running my devicenet communication. I am both writing and reading some information in this loop.
When the user presses a button, I am supposed to give certain type of information to my main while loop executing DeviceNet. This information varies with time, and hence I wrote a Event structure to execute this subroutine. This Event structure, I put it inside another while loop, and placed this alongside the main while loop.
Now, when I want to stop the program, the main while loop can be terminated using a boolean control, but the Event continues to run and my program never ends. How can
I end the whileloop of the event structure, when I am ending the main while loop. Using a local variable of the boolean control to stop the whileloop of the event, does not work.
Please help me get around this problem.
Thanks.
0 Kudos
Message 5 of 10
(3,477 Views)
Hi Jumarion,
Thanks a lot,
I have a question...will this work if I create a exe file of Program1 and run the exe??"
0 Kudos
Message 6 of 10
(3,477 Views)
Hi Shreesha,
it should work, but I only have an FDS edition of LabView so I just can't try it. The thing is that if you've got an exe, you have to give the correct path for program2. This path can be different in debug mode and in an exe file.
I didn't really understand what Zvezdana meant : "Program 2 has to be open". You only need to tell program1 where is program 2 on the disk and that's all.

Hope this helps !
Julien
0 Kudos
Message 7 of 10
(3,477 Views)
Shreesha,
Although the Event structure is in a different loop then where the Boolean control that stops the first loop is, you can still set up and event for this Boolean. Then just pass a true constant out of this event that will stop the second loop.
Please find the attached VI.
0 Kudos
Message 8 of 10
(3,477 Views)
Julien and Shreesha,
What I meant by 'Program 2 has to be open" is that Program1 will run Program2 dynamically, but will not open its front panel. Program1 doesn't launch the front panel of Program2, it just runs Program2 in the background.
To actually see the Program2 open, and be able to stop it by clicking on the Boolean on its front panel, you have to use the FP.Open property node, or have Program2 front panel opened before clicking on "Lauch Progam 2" boolean in Program1.

Zvezdana S.
0 Kudos
Message 9 of 10
(3,477 Views)
OK Zvezdana ! I understand what you meant now and you're absolutely true.
Sorry for that ! Thanks for the answers.

Julien
0 Kudos
Message 10 of 10
(3,477 Views)