Jump to content

Current VI's Reference

Recommended Posts

I recently found a new way to get the reference of the current VI. There are several ways to do this but I think this new one is the cleanest I have seen so far.

The original way I used to do this was to open a VI reference to the tip of the call chain, as shown in the 'old way.jpg' attachment.

The problem with this method is it requires you to later close that reference (every open must have a close).

The second method I started to use was to drop a property node and link it to the VI. I would simply not use the output property. This is shown in the 'second way.jpg' attachment.

The new way is to just create a reference that is linked to the VI. I stumbled across this when playing around with passing object references to subvis. The only problem I see is there is no direct way to create this reference. You must always first create a reference to some FP object and then relink it to the VI itself. See the 'new way.jpg' attachement.

Does anyone know of any advantage or disadvantage to any of these methods?



Link to comment

QUOTE(jlokanis @ May 24 2007, 06:17 PM)

Does anyone know of any advantage or disadvantage to any of these methods?

Methods 2 and 3 (property node ref and This VI ref) are functionally the same if you don't wire the output of whatever property you're reading. They return a "Self Reference" to the VI that does not need to be closed. Instead of dropping a control ref and re-linking it to the VI, you can drop a "This VI" reference from the Application Control subpalette.

Ooh, now that I think about it, that reference may drop as "This App" instead of "This VI"...I don't have LabVIEW open right now. Either way, This App/This VI are the top two choices on the top of the list when you operate-click the reference.

Hope this helps,


Link to comment

ZITAT(jlokanis @ May 25 2007, 01:17 AM)

Does anyone know of any advantage or disadvantage to any of these methods?

There is one key feature:

If you want to hold a VI to itsself for hidden top level execution, the only way is to

use the "Open VI Reference" primitive. Otherwise, the execution stops immediately,

if you close the front panel.


Link to comment

Open VI reference opens a dynamic reference. If the VI is reentrant, then a new reentrant clone of the VI is opened and a reference to new instance is returned. Closing this reference also closes the VI or for reentrant VIs the VI clone.

The other two methods are static references as Darren said. These references LabVIEW automatically closes when the VI is closed or clone VI is closed for reentrant VIs. Trying to close them explicitly has no effect. These references do not affect the lifetime of the VI.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.