LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Invoke Node Method: Close FP (LV7)

LabVIEW Masters:
If an Invoke Node is used with the Close FP method, does any code remaining after the Invoke Node execute? Specifically, if you've invoked the Close FP Method (on the same top level VI that is calling the function) and then follow this function with the Close VI Reference function (for the same top level VI), does the Close VI Reference function ever execute? I'm aware that by closing the Front Panel the top level VI and all sub-routines are released from memory so is it necessary to call the Close VI Reference function as well?
0 Kudos
Message 1 of 4
(4,303 Views)

Hi Steve,


Sorry no master, just Ben.

Interesting question. I put together the attached VI to see if I could answer this Q for myself.

The bottom line depends...

If you want your VI to play nice and be usable as a dynamic VI called from a bigger badder VI TestStand, etc. you should close the reference.

When you invoke the close FP method that closes the FP, Yes.
If that VI is the only VI in memory and you exit LV, then get cleaned-up in your behalf when LV exits. In this case it is not required to lose the reference, but,

"Flame suit on"

It is concidered bad style.

"flame suit off"

If you trying running the LV7 demo I posted and open another new VI, then look at the VI hiarchy screen you will see what I mean.

The demo I posted uses an event structure with a case structure in the timeout event case. This case lets you determine from a front panel boolean if the code executes an invoke node close FP. After the invoke node there is a seq structure that drives a boolean indicator to let you know the code following the invoke node does execute.

The example also lets you experiment with close the VI ref. If you run the example and allow all of the references to be closed, then a front panel close event will close the VI and un-load it from memory. Closing a VI ref can be thought of as being an official way of telling LV "I do not care about this VI any more, unload it no no else cares either". If you le tthe demo loop a couple of times opening ref to itself and then start shutting down the refs, you will see that VI will say in memory.

The example also shows that you can set up an event case that will fire on the close FP event giving you the ability to abort the operation programaticly. This demonstrates that the can run well beyond the close FP.

The demo also illustrates DR VI's rule "if the refnum changes, close it" by type casting the ref's as an array of I32's.

Summarizing:
IF this is a top level "quicky" VI you do not HAVE to close the reference. You can get away with just the invoke node close FP.

If you want to write re-usable code that will load and unload in a predictable manner, close the ref.

Sorry about the rambling, I hope this makes sense,

Ben


Ben Rayner
Certified LabVIEW Developer
www.DSAutomation.com

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 4
(4,303 Views)
Very Slick. Thanks for the indepth reply. It certainly has helped. I've just been playing it safe and closing all references. It was indeed the creation of a "bigger badder VI" in which I came to wonder about this. Thanks for clearifying.

Steve
0 Kudos
Message 3 of 4
(4,303 Views)

"I've just been playing it safe and closing all references"

Good go! Someone will benefit by this appraoch. It may even be you.

Thanks for the kind words.

Ben


Ben Rayner
Certified LabVIEW Developer
www.DSAutomation.com

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 4
(4,303 Views)