LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the path for text data files?

I have a single main .vi that calls three sub .vi files.  In each of these sub .vi files, there are text data files that are created, opened, closed, written to, etc.  Currently it is a constant path for these files. However I want to be able to make this application a .exe and have it run in any directory.  I was planning on using the "current vi path" vi and using that to create a ./data direcotry for these files.  Is this the best way to do this?  Will it still work when everything is placed in a .llb or .exe?
0 Kudos
Message 1 of 4
(2,980 Views)

If you use Current VI's Path in an EXE, you'll have to strip the path twice, since the path to your VI when it is built into an EXE will be c:\temp\blah.exe\my.vi.  Notice how the EXE path is thrown in there?  Anyway, if you search the forums you'll find this issue discussed several times...some people use the App.Kind property of the Application class in VI Server to determine how many times to strip the path, while other people get the path and search it for '.exe' to see if it's got EXE inside it.  Personally I think using the App.Kind property is the easiest way to go.

Good luck,
-D

0 Kudos
Message 2 of 4
(2,973 Views)

Thanks.  Currently I call the sub .vis by using the current (main) .vis path and stripping it once.  So if I built an .exe even the calls to the sub .vis would stop working?  So if I had all of the sub .vis in a .llb and then made an .exe, I would have to strip 3 times to write a file to the current directory from one of these sub .vis?

strip this three times: 

\programs\XXX.exe\XXX.llb\XXX.vi

to get:

\programs\

 

 

0 Kudos
Message 3 of 4
(2,960 Views)
If you include the dynamically called subVIs in the build, then they will be included in the exe file. The path is not \XXX.exe\XXX.llb\XXX.vi. It is just \XXX.exe\XXX.vi. A LabVIEW exe is really a type of llb. You can rename an exe to llb and use the Edit VI Library to see the names of the VI and subVIs. If you put the subVIs in a separate llb from the exe, then from one of the subVIs, to get the current directory, you still only need two strip paths. A handy way to test whether your exe will work is to save everything in an llb first as the structure of an llb is exactly the same as an exe. Just don't get into the habit of saving your development VIs in an llb.
0 Kudos
Message 4 of 4
(2,953 Views)