LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you use open by reference for subvi within an executable

tl;dr
I don't think you can open a VI reference in an executable, if when it is executable form, that subvi doesn't actually have a path. Do I need to include the VI in the executable, does it work differently when it is in executable form, or should a be doing something different entirely.

GrumpsMcGurt_0-1747675581756.png

Long Version:
I am just kinda flailing around trying to make code work, so pardon my ignorance. I am wrote an executable for some data collection (yay, my first labview software) and now I am trying to retrofit it for some UI functionality.

I wrote some software that lets me manipulate the front panel settings (Mod FP.vi) and save them in a config file so I can hopefully load the front panel in different states based on who is using it. Assuming all of that works in an executable form, I am now trying to make some software that will let me open and manipulate the front panel of any of my subvi without Mod FP.vi being called by the Vi I want to manipulate. The bit of code I am testing this concept with gets a reference to the subvi by using Open VI Reference, but I think this might fall apart once I turn this into an executable, because within the executable that path just doesn't exist. This code right now works exactly the way I want it to, but I don't know how this works when it becomes an executable. 

So really the question here is does this work as written within the Executable?

Sorry if this seems like I am just too lazy to test, I just am on a new PC and my application builder license is yelling at me.

0 Kudos
Message 1 of 5
(146 Views)

Hi McGurt,

 


@GrumpsMcGurt wrote:

So really the question here is does this work as written within the Executable?


Yes, it will work inside an exe - as long as you provide the correct path!

 

I recommend to use the ApplicationDir file constant to build the path to your subVI - or use a static VI reference instead…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(139 Views)

Thanks, this was ridiculously helpful.

The StaticVi reference seems like the way to go for me, that being said...

I have been doing this:

GrumpsMcGurt_0-1747680821904.png

The entire time, I had no idea the ApplicationDir was a thing.

0 Kudos
Message 3 of 5
(118 Views)

Hi McGurt,

 

instead of using string functions an drelying on specific chars to denote folders ("\") you should use the BuildPath/StripPath functions!!!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(110 Views)

In addition to what Gerd just said, you should also use the application directory instead of current VI path.

 

(Using string functions on paths is also dangerous, because they will all break on a different OS and there is the potential to make illegal file names.)

0 Kudos
Message 5 of 5
(104 Views)