05-10-2017 10:29 AM
Hi there,
I'm having a problem building a path to my config file because it gets called from TestStand, allow me to explain. Normally for LabVIEW development I have a disk hierarchy like this:
- Project Folder
- Project.lvproj
- Config Files
Config.ini
Then when I use "Application Directory" I get back "Project Folder" and can easily build the path to my config file. When I build the executable, I don't need to change anything, and the disk hierarchy looks like:
- Application Folder
- Application.exe
- Config Files
Config.ini
Now the application directory is "Application Folder" but I still build the path to the config file the exact same way.
However, when I call the code from TestStand, the application directory is that of the TestStand executable. I forget exactly what it is, but for the sake of discussion let's say "C:\Program Files (x86)\National Instruments\TestStand\" which is nowhere near my config file...
So should I get the path of the VI, and strip the path until I get back up to the .lvproj directory? This could cause problems if I ever change the disk location of the VI that loads configs. Any other suggestions?
Thank you,
Gregory
Solved! Go to Solution.
05-10-2017 10:40 AM
Instead of using "Application directory" you may wish to use "Get System Directory".
There's 14 options on which directory to get and it's completely independent of where the file runs from.
It will be slightly less convenient as it does mean that the INI file will be stored in a directory different from the VI or EXE.
05-10-2017 10:58 AM
Does the Current VI's Path not return the directory of the built EXE? You'll have to make a case structure that if the application is run from a project, use this path. Otherwise use that path. I've never used Teststand so I'm not familiar with it.
05-10-2017 11:45 AM
In TestStand, you can get the sequence file's path and pass that into your VIs to find your config file.
05-10-2017 11:56 AM
@aputman wrote:
Does the Current VI's Path not return the directory of the built EXE? You'll have to make a case structure that if the application is run from a project, use this path. Otherwise use that path. I've never used Teststand so I'm not familiar with it.
No, it returns the VI's location within the executable. I am trying to use this case structure idea, but the problem is that RUN_TIME_ENGINE==True when running from TestStand or from an EXE, but the paths will be different
05-10-2017 11:58 AM
@crossrulz wrote:
In TestStand, you can get the sequence file's path and pass that into your VIs to find your config file.
Thank you for the idea. The way all of our LabVIEW modules are stored on disk is in an uncontrolled folder and controlled folder, and then in the folder corresponding to the module's internal tracking number followed by revision. I'm afraid if we changed the revision or go from uncontrolled to controlled then it will also cause the path to be incorrect.
05-10-2017 12:14 PM
For now a quick fix is to use the Application App.Name property. For development environment it will be "Labview.exe", for TestStand it will be "SeqEdit.exe", and for a built application it will be "[Application Name].exe". I just made it so the built application uses the Application Directory and all other options it will be relative to the VI location. Not great if I change the name of my built application or rearrange my VIs on disk relative to the config file, but I don't plan on actually using the built executable, I just build it every once in a while to check runtime environment behavior.
05-20-2017 04:16 PM
An additional option could be to check the "Execution.State" property of the MAIN VI. I have not used Teststand, but I suspect that the VI's execution state when called from Teststand will be reported as "Run" as opposed to "Run Top Level" when running on its own. You could use that check along with the "App.Kind" property to adjust config pathing for all of your execution cases.