LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

object reference in built application

Solved!
Go to solution

Currently I reference a support directory in a top level VI by using the [Current VI's Path], [Strip Path] and appending "/data" to the returned file path. When I build the application my reference is no longer valid as [Current VI's Path] returns "Root/Directory/Application.exe/TopLevel.vi" instead of "Root/Directory/TopLevel.vi".

 

My question is how can I reference my Support Directory specified in the Application Builder within my code? If thats not possible how can I reference a file path that will stay valid in source and as a built application? I would not like to have to ensure default directories are the same across machines.

 

Thank You,

 

Mike

0 Kudos
Message 1 of 4
(3,179 Views)

Hi Mike,

 

You can use a property node to determine if you are in development mode or runtime mode. Then strip out the exe name when in runtime. 

 

Place a property node and select: application - kind

Set up a case structure to make your selections.

(In the snipit below I show two case structures just to show both names.) 

 

steve

 

app kind.png

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 2 of 4
(3,168 Views)
Solution
Accepted by topic author MikeBoso

I would suggest doing something like this, because it will work in all combination (IDE, EXE, LLB, etc.).

 

 

You should note, however, that LV 2009 changed the way VIs go into an executable. If you're getting the path of the top level VI, you'll be fine. If you're starting from the middle of the hierarchy, however, you will get T from the Is Directory output while still inside the EXE, because the folder structure is maintained inside the EXE.

 

To work around this, LV 2009 also has a new VI in the file constants palette which returns the directory of the current application. This is what you should use if you're using 2009.


___________________
Try to take over the world!
Message 3 of 4
(3,159 Views)

Thanks Steve and tst. I have tested both approaches and they both work for what I was intending to do. Sorry for duplicating a thread!

 

Mike

0 Kudos
Message 4 of 4
(3,153 Views)