LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling a vi from a main vi


@rrr1 wrote:

Yes, I do.

 

What I need is to have a main VI that has 3 buttons. When you press the first one, another VI has to open in a new window. When the user closes that one, he should press the second button that opens another VI, and finally, he should press the last button that opens the last VI.

Neither of the subVI need information from to main VI nor transfer info to it.

They only need to be opened when the corresponding button is clicked, and each subVI can be clossed only by clicking the "X" button in the top of the window.

 

It's actually pretty simple!!

 

Thank you very much!!!! 


go into the sub vi properties under window appearance, click on custon and customize button, click show front panel when called and close afterwards if...uncheck allow user to close window and check modal, then goto window run-time position and position will be centered...

on the block diagram, include the vi property fp.closeable to true...that's it, simple?

 

did you really look into the example i posted?

0 Kudos
Message 11 of 22
(1,138 Views)

I just saw that you answered. I have another question. I'll post it so while I'm reading your answer, maybe you can help me.

 

and yes, I did check your posted example and it's helping a lot

 

I know that I'm asking too much! 😞

I don't know if you got my proyect.

The question is: I see that when I finally get the subVI running, when I close it, it says that it stays in the memory.

My app is going to be run in computers that have low performance. Is that going to be a problem?

 

Rrr

0 Kudos
Message 12 of 22
(1,134 Views)

Apok - why set the Closeable property to true after the while loop ends? Is your goal to make sure that the user can't close the window until after the VI has stopped executing?

 

The right way to catch the user clicking on the close box is with an event structure. Then you can clean up and stop the VI when the window is closed. Otherwise it will continue executing but with the front panel hidden, and your main VI will continue to be blocked because the subVI is still running.

0 Kudos
Message 13 of 22
(1,134 Views)

Apok,

 

Your help has been just awesome...

 

One question: why is it possible that the first time I run the subVI the user cannot close the window (as you told me to set it in window apperance, which is great!!) but if I click the run button again, the user CAN close the window?

It seems pretty extrange. I uncheck the "allow user to close window" and save it, and each time that I open it again after running it, it appear checked.. :s Don't have a clue why actually it's not saving the uncheck.

 

Another question (and I don´t know if you do know this) is that when I create an executable of this proyect, how can I tell the .exe that the main VI is the one that it is so it only opens that one? I think that It would work correctly because the other would be close because I'm not invoking then until I click each run button, but how can I be sure?

 

Thank you SO much in advanced already!!

 

Rrr

0 Kudos
Message 14 of 22
(1,119 Views)

rrr1 wrote:

It seems pretty extrange. I uncheck the "allow user to close window" and save it, and each time that I open it again after running it, it appear checked.. :s Don't have a clue why actually it's not saving the uncheck.


Probably because of the "Closeable" property node that apok seems to think is necessary. You uncheck the "Allow user to close window" setting. Then you run it, and the Closeable property gets set to True when the VI stops, which effectively clears the checkbox in the settings. Then the next time you run it, the Closeable property is already set true, so the user can close the window (although that doesn't stop the VI from running).

 

Again, this is completely the wrong approach. To get the behavior you want, where the user can close the window by using the Close box, you need to have the "Allow user to close window" setting checked. Add an event structure to your VI, and catch the "Panel Close?" event. When that event occurs, stop your VI. If you also have the "Show front panel when called" and "Close afterwards if originally closed" properties set, the VI will close when it stops (assuming you didn't already have the VI open when you started the main VI).


rrr1 wrote:

Another question (and I don´t know if you do know this) is that when I create an executable of this proyect, how can I tell the .exe that the main VI is the one that it is so it only opens that one? I think that It would work correctly because the other would be close because I'm not invoking then until I click each run button, but how can I be sure?


Try building an executable and I think it will be obvious - you set a single VI as the startup VI for the application.

0 Kudos
Message 15 of 22
(1,110 Views)

@nathand wrote:

Apok - why set the Closeable property to true after the while loop ends? Is your goal to make sure that the user can't close the window until after the VI has stopped executing?

 

The right way to catch the user clicking on the close box is with an event structure. Then you can clean up and stop the VI when the window is closed. Otherwise it will continue executing but with the front panel hidden, and your main VI will continue to be blocked because the subVI is still running.


to close the FP, otherwise it will stay open on the desktop...this does not continue to execute and hide the front panel as you say, the loop is exited after UI stop??

0 Kudos
Message 16 of 22
(1,107 Views)

@apok wrote:

to close the FP, otherwise it will stay open on the desktop...this does not continue to execute and hide the front panel as you say, the loop is exited after UI stop??


The original poster wrote "each subVI can be clossed only by clicking the "X" button in the top of the window" so why would you provide an example where you need to press a stop button on the front panel first, and THEN click the X button? Once the VI is stopped, no reason to require a second click to close the window. If you want the VI to stop running and close when the user clicks the X button on the window frame, the way to do it is with an event structure. In your example, if the VI is already closeable when it is still running, then closing the window leaves the VI running; and if the VI isn't closeable when it's running, then you're not doing what the poster requested.

0 Kudos
Message 17 of 22
(1,101 Views)

@nathand wrote:

@apok wrote:

to close the FP, otherwise it will stay open on the desktop...this does not continue to execute and hide the front panel as you say, the loop is exited after UI stop??


The original poster wrote "each subVI can be clossed only by clicking the "X" button in the top of the window" so why would you provide an example where you need to press a stop button on the front panel first, and THEN click the X button? Once the VI is stopped, no reason to require a second click to close the window. If you want the VI to stop running and close when the user clicks the X button on the window frame, the way to do it is with an event structure. In your example, if the VI is already closeable when it is still running, then closing the window leaves the VI running; and if the VI isn't closeable when it's running, then you're not doing what the poster requested.


there is no second choice (X) to close the front panel...only one (UI stop control), that was changed in the properties? if you can do this simple vi...then show us?

 

tell me how the sub vi is still running after the loop has exited on "stop"........??? exiting a vi by stopping the loop is cleaner than hitting the X

0 Kudos
Message 18 of 22
(1,097 Views)

@apok wrote:

there is no second choice (X) to close the front panel...only one (UI stop control), that was changed in the properties? if you can do this simple vi...then show us?

 

tell me how the sub vi is still running after the loop has exited on "stop"........??? exiting a vi by stopping the loop is cleaner than hitting the X


See attached code. If I'd had time earlier I would have done that first, but today has been really busy so I thought maybe I could help by explaining briefly rather than coding. This demonstrates how you can start a VI both synchronously (main VI loop waits until subVI completes) and asynchronously (the loop that calls the subVI continues running after launching the subVI).

 

Note that this code stops the loop and closes the window when the user clicks the close box (and, for added certainly, it prompts the user to make sure they intended to close the window). This is clean and consistent with the way most programs work.

 

What I was saying is that in your example, if the user doesn't click the stop button first but does close the window (because the window is marked closeable from the previous run), the VI will still be running after the window closes because the loop was never stopped and with the window closed there is no way to stop it.

0 Kudos
Message 19 of 22
(1,088 Views)

nathan....I dont want to go round and round here, your sub vi's take 2 clicks to exit, while my example uses (stop) one click to exit the loop and shut down front panel , without the option to use (X) as i disabled that option in the vi properties.

 

Respectfully last post for me...

0 Kudos
Message 20 of 22
(1,083 Views)