06-05-2015 06:36 PM - edited 06-05-2015 07:03 PM
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,
Solved! Go to Solution.
06-05-2015 10:07 PM
06-06-2015 12:52 PM
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...
06-06-2015 02:21 PM
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
06-07-2015 02:42 AM
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.