LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open VI reference from a static reference

Solved!
Go to solution

Hello guys,

To open VIs dynamically, instead of hardcoding the VI name in a string constant, I do this as shown below to keep a dependency to my VI, so if someone ever delete the VI from the project, move it, rename it, it will create a broken wire somewhere so we'll be able to fix it faster.

 

However, don't you think it's a bit weird to have the reference to the VI already, but we need to open a new reference, is there a way to get rid of the property node to get the VI path? Is the static VI reference should be closed after the other reference is opened?

 

Would it make sense to be able to right clic the static reference and specify the option to open a call and forget reference?

 

Is there a better practice?

Cheers,

2015-06-05 16_26_46-hpht.lvlib_hpht.warning.vi Block Diagram on ABT.lvproj_My Computer rev. 21 _.png

0 Kudos
Message 1 of 5
(3,795 Views)
You don't actually need the path in this situation. Because the static ref is holding the vi in memory, all you need is the vi name.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,761 Views)
Solution
Accepted by topic author JimChretz

Mike, I seem to recall there was at least at one time some subtle difference on using name vs. path (I think about needing the root loop), but I'm not sure about that. In any case, I don't think it makes any actual difference.

 

As for the original point, it is correct that it wouldn't be techincally a requirement (at least as long as you don't need special options like reentrancy). You can vote for this if you want it changed - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-Asynchronous-Call-By-Reference-with-Strict-Stati...


___________________
Try to take over the world!
Message 3 of 5
(3,734 Views)

I use the VI Name property rather than VI Path.  The nice thing about this method is that it works both in Development Mode (when you are testing the Code) and in the Built Executable.

 

Bob Schor

0 Kudos
Message 4 of 5
(3,721 Views)

From the LabVIEW help:

 

 

vi path accepts a string containing the name of the VI that you want to reference or a path to the VI that you want to reference. If you wire a name string, the string must match the full delimited name of a VI in memory on that target. If you wire a path, LabVIEW searches for a VI in memory that you previously loaded from that path on the same target. If a matching VI is not found in memory, LabVIEW then tries to load the VI from that file on disk. An error occurs if LabVIEW cannot find the file or if the file conflicts with another VI in memory.

 

 

So, basically, if you use the string, you load the VI in memory and get an error if not found.  If you use path, it will still use the VI in memory at that path, or attempt to load it.  In your case, it won't make much difference.  I typically use VI Name myself since I know it is in memory.

0 Kudos
Message 5 of 5
(3,679 Views)