09-03-2020 09:45 AM
The question has to do with the Application Directory VI.
The help file says:
If you call this VI from the development environment and the VI is loaded in a LabVIEW project file (.lvproj), this VI returns the path to the folder containing the project file. If the project is not saved, this VI returns <Not a Path>.
If the top-level VI is not loaded in a project, the VI returns the path to the directory containing the top level VI. If the VI is not saved to disk, this VI returns <Not a Path>.
Is there a way to programmatically check if the top level vi was loaded from within a project? That way I could adjust the path for either case.
I have a project that is still in development but currently being used that loads a configuration file. I open the program using the project but the user will open it from a desktop link to the VI for now. I know there are a few other ways around this, but I thought I would ask because I am curious.
Bryan
Solved! Go to Solution.
09-03-2020 10:24 AM
I'm not sure where, or if, this is documented, and also am unsure if it is a Fluke or a Feature, but I've done the following successfully:
This doesn't directly answer the question you asked, but it may help you "do it another way".
Bob Schor
09-03-2020 10:53 AM
Thanks for the additional info Bob.
09-03-2020 11:03 AM
You could do something like this to see if the project in question is open. If the VI is running and the project is not open, that's basically a guarantee that it was loaded by itself rather than from the project. Unless of course he has a project with the exact same name open.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
09-03-2020 12:52 PM
@FireFist-Redhawk wrote:
You could do something like this to see if the project in question is open.
Or slightly simpler.
09-04-2020 03:24 AM
09-04-2020 06:43 AM
I get a Not a Refnum when running that without a project open. So you'd have to add a little something something...
Plus that would start behaving a little weird with multiple projects open.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
09-04-2020 06:48 AM
wiebe@CARYA wrote:
Could it be this simple?
Interesting, but I have not enabled scripting yet. I should probably start looking into what scripting has to offer.
09-04-2020 06:51 AM
@FireFist-Redhawk wrote:
I get a Not a Refnum when running that without a project open. So you'd have to add a little something something...
Ah, didn't test that. I did remove it from the project I made it, and got the "Main Application Instance".
@FireFist-Redhawk wrote:
Plus that would start behaving a little weird with multiple projects open.
I don't think so. You'd expect it to return one of the open projects if the VI is not in a project, but you'll get "Main Application Instance" instead.
09-04-2020 07:02 AM
@FireFist-Redhawk wrote:
Plus that would start behaving a little weird with multiple projects open.
It does get weird.
I got "Main Application Instance", but only because the project was not active. So it worked coincidentally.
How about this (even simpler):
Getting the name of the project would be trivial, but the goal as I get from the thread title is to know if the VI runs in a project or not.