LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI used in project not taking correct path in exe

Solved!
Go to solution

Hi All

I am facing a issue when buuilding exe of my project. I have used one subVI(Placed inside SubVI folder) which is reading the excel file palced under cofniguration folder. For this I have taken "Current VIs path function .In development system environment I am striping path 2 times to reach to configuration folder and read the excel .Its working correctly. When I am building exe I have striped the path one more time extra (total 3 times)and expecting that it should read the file.  As the "cuurrent Vis path function will give outputs as : "ExePath\Exename\subVI\Readfile.vi"

However in the exe , subVI's path is not taken from the exe and it is taken from the project folder only(i.e: C:\Software\ProjectName\SubVI\Readfile.vi). Due to this even after striping path 3 times its not reading the file correctly.

What could be the reason for this?

I am attaching the folder structure of the project.

 

0 Kudos
Message 1 of 8
(4,542 Views)
Solution
Accepted by LV_user1

Hi LV_user,

 

recommended method is to use the AppDir constant (file constants palette). This will give you the folder where your EXE is located in…

 

To your question: we do not know how your subVI is embedded in the EXE. We do not know your BuildSpecs. We do not know your  LabVIEW version.

We do know NOTHING to elaborate an answer for you…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(4,521 Views)

Hi


Thanks for the reply!


I have build an application using LabVIEW version 2012. SuBVI is embedded in the project in always incluuded section of the application builder under source files. Also in souurce file settings , subVI folder settings is as per the screeshot attached.


Main VI is the startup VI for the application.


When I am running the  exe ,I am getting the OP of getCurrent VI path function as :  C:\Software\sample.exe\Test\Code\SubVI\readfile.vi whereas I am expecting the OP as C:\software\sample.exe\subVI\readfile.VI .(C:\Test\Code\subVI\readfile.VI is the path where my project is located).

 

 

0 Kudos
Message 3 of 8
(4,500 Views)

Hi LV_user,

 

When I am running the  exe ,I am getting the OP of getCurrent VI path function as :  C:\Software\sample.exe\Test\Code\SubVI\readfile.vi whereas I am expecting the OP as C:\software\sample.exe\subVI\readfile.VI .(C:\Test\Code\subVI\readfile.VI is the path where my project is located).

In an EXE the VIs are stored in the same relative file position as they are in the project. So you get the very same folder/subfolder structure in the EXE!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 8
(4,490 Views)
When building paths in executables the basic question you have to answer is whether the file is a LabVIEW file (that will go inside the executable) or a non-LabVIEW file (that cannot).

As long as you're organized, the suggestion that Gerd gave will always work for non-LabVIEW files. The reason is that as he said, in an executable it returns the path to the exe. It works in development as well because in the development environment it points to the path to where the proj file is located. As long as the relative paths are the same -- you're golden.

Finding paths to files inside the exe can be a bit trickier. One way of doing it is to start with the curent VI path and strip or build as needed to navigate to where you want to go. That will work, and work well as long as you don't move files around or rearranging your directory structure. Then it can become a pain...

Something I have been doing lately is to implement a simple couple conventions that save me a lot of time and heart ache.

1. The top level VI (the one that launches in the executable) is always in the same directory as the project file and is named to match the project file. For example, if the project file is...

"my project.proj"

...the name of the top level VI is...

"my project.vi"

2. The first thing that the top level VI does when it starts is store its own path in a FGV. Because of convention 1, this path will always be a known starting point for building paths to things inside the executable in the same way that the application path node is a known starting point for files outside the executable.

I have a more complete description (and typical code) on my blog. The link is in my signature and you should start reading from the beginning. The posts build on one another.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 8
(4,488 Views)

HI GerdW and MikePorter,

 

 

Got the point!

I am now using application directory to get path of exe when running exe. Till now i was in impression that when we build exe the path for the VIs/SubVIS are taken from the exe and not from the base root folder path.

and hence while building exe we have to strip our path one more time compared to the development system environment. I have done the same thing seveal times and it worked.

If in exe also it takes the subVIs path from the base folder (for eg: C:\software\sample.exe\test\code\subvi\readfile.exe instead of C:\software\sample.exe\subvi\readfile.vi) then why we always say that we have to strip one more time extra while building application? Not clear to me ... and hence I am repeating the question... sorry for it!!

 

0 Kudos
Message 6 of 8
(4,462 Views)
In terms of what you have heard, you were perhaps talking to someone who was using the old internal exe structure -- or were reading an old forum post. With older versions of LabVIEW the advice was indeed to "strip one extra time" in the executable.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 8
(4,439 Views)

Hi Mike

 

Ohh...this indeed was a good information for me!! I have always build executables till LabVIEW 2009 and i guess it was in the same format which i mentioned.

I guess from LV2012 this internal exe structure is changed.

Thanks for the information!!!

0 Kudos
Message 8 of 8
(4,417 Views)