h1voltage Posted July 17, 2007 Report Share Posted July 17, 2007 Hello Everyone, Is there a flag indicating whether or not a VI is actually a VI (.vi) or in executable form (.exe)? I need this so that I can conditionally find the relative path. Using the "Current VI's Path", you get the exe's path with the actual VI name appended to it (i.e. - C:\Projects\My Application.exe\Application.vi) Any thoughts? ~Zack Quote Link to comment
Yair Posted July 17, 2007 Report Share Posted July 17, 2007 The Application class has a property called Kind which will return an enum telling you whether you're running inside LabVIEW or in a built executable. You can get it simply by dropping a property node on the diagram. Quote Link to comment
ooth Posted July 18, 2007 Report Share Posted July 18, 2007 Here are some VIs that I use. I cannot find where I got them and I'm sorry to the author for not siting his/her work. The CallerIsExe.vi is the one that will help you. Just drop it in a VI and wire the Current VI's Path constant into it. Quote Link to comment
Yair Posted July 18, 2007 Report Share Posted July 18, 2007 Relying on the exe extension is problematic. You might have a file which is not an executable file but has an exe extension or you might have a directory which has an .exe at the end of its name or you might be running on Linux or Mac, where you don't have the extension. A better way would simply be to use the property I mentioned and then output T or F based on its value. Another option for simplifying the subVI as it is now is to to use the Call Chain primitive and index out the second element, which would be the calling VI. You can then open a reference to it and get its path using a property node instead of having to wire its path into the subVI, but I would advise the first method. As for the base path VI, it suffers from the same basic problem. I prefer the OpenG method, which is basically getting the path of the VI (using the method I mentioned) and then stripping in a loop until the File/Directory Info primitive returns T in its directory output, like this quick example (which does not do error handling): http://forums.lavag.org/index.php?act=attach&type=post&id=6380 This is also platform independent. Quote Link to comment
Jon Sweeney Posted July 18, 2007 Report Share Posted July 18, 2007 QUOTE(ooth @ Jul 16 2007, 11:01 PM) Here are some VIs that I use. I cannot find where I got them and I'm sorry to the author for not siting his/her work. The author's name is included in the context help documentation. Quote Link to comment
ooth Posted July 18, 2007 Report Share Posted July 18, 2007 Yen, Those are very good points. I'll start using the Kind property now. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.