LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change VI Title using Pre-Build Action

Hello,

 

I am trying to change the Window Title of a VI when I build it into an exe.  However for some reason it doesn't work.

 

Attached is some sample code that illustrates the problem.  When I run the Pre-Build Action vi by itself it changes the title.  When I use the application builder it doesn't work.

 

Any help would be appreciated.

 

Thanks

Dan Shangraw, P.E.


   

0 Kudos
Message 1 of 10
(3,605 Views)

Hi Dan,

 

when my memory is correct then the AppBuilder creates a cahce of all the VIs when building the app before the PreBuild-actrion is called. Any changes made by that action will not influence that cached items.

 

You need to start the AppBuilder twice to implement your PreBuild-changes into the executable…

Best regards,
GerdW


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

I can't open your project since I don't have a new enough version of LabVIEW, but what you describe should be possible.  I do something similar with a pre-build action in a project that definitely works in LV 2018 SP1, though I don't modify VI properties, but instead modify the default value of a string control within a VI.

 

The sequence I used within the pre-build action VI goes something like:

obtain static reference to VI >> return path on disk to VI using property node >> close static reference >> read subset of text from build specification using project reference >> open a NEW reference to the VI using the path on disk >> set value of string control by name using the NEW VI reference >> "make current values default" method using the NEW VI reference >> "save instrument" method to save the VI changes using the NEW VI reference >> close reference.

 

I remember this being a pain to get working originally, but I don't remember the details of it anymore.  Opening the NEW reference using the path on disk obtained from the static reference may have been thing thing that finally got it working for me.  Its something to give a try, at least.

0 Kudos
Message 3 of 10
(3,560 Views)

The reason for doing this is to display the rev number in the title of a built exe

 

Using the pre-build is a dead end.

 

What I did is create a vi to get the rev number and display it in the title.  I run this vi on initialization

 

You will need OpenG and the MGI toolkit to run this vi

 

Works great!

Dan Shangraw, P.E.


   

0 Kudos
Message 4 of 10
(3,556 Views)

So someone doesn't come across this thread and get the wrong impression, it IS possible to do this with a pre-build action.  Attached is a working version.  The main thing missing was just programmatically saving the VI after the custom title had been altered in the pre-build action.

0 Kudos
Message 5 of 10
(3,543 Views)

Thanks for posting!

 

I tried programmatically saving but didn't have any luck.  Must have been doing something wrong....

Dan Shangraw, P.E.


   

0 Kudos
Message 6 of 10
(3,540 Views)

You're welcome. Yeah they specific method is weird, something like "Save" -> "Save Instrument" is the one to pick.  Could also have something to do with file permissions or user account settings.

0 Kudos
Message 7 of 10
(3,534 Views)

Hi Dan,

 


@ASTDan wrote:

The reason for doing this is to display the rev number in the title of a built exe

 

What I did is create a vi to get the rev number and display it in the title.  I run this vi on initialization


I solve this by setting a version number in the BuildSpecs (Version info -> Description).

You can read this information in your executable using the FileVersionInfo function from "vi.lib\platform\FileVersionInfo.llb\" and set the VI title dynamically inside your executable…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(3,532 Views)

@playerm1 wrote:

So someone doesn't come across this thread and get the wrong impression, it IS possible to do this with a pre-build action.  Attached is a working version.  The main thing missing was just programmatically saving the VI after the custom title had been altered in the pre-build action.


When I try running it, the build fails.

bf.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 9 of 10
(3,510 Views)

@GerdW wrote:

Hi Dan,

 


@ASTDan wrote:

The reason for doing this is to display the rev number in the title of a built exe

 

What I did is create a vi to get the rev number and display it in the title.  I run this vi on initialization


I solve this by setting a version number in the BuildSpecs (Version info -> Description).

You can read this information in your executable using the FileVersionInfo function from "vi.lib\platform\FileVersionInfo.llb\" and set the VI title dynamically inside your executable…


Whilst I would also be tempted in this case to do as GerdW describes and change the title in the running executable, you could also write a (normal, not "pre-build") VI that sets the title programmatically, and then acquires a reference to the Application Builder spec and runs it (or indeed, create your build spec from scratch and run that, but it's probably unrelated to the need you describe here).

 

The Application Builder VIs you're looking for for an application build-spec are probably something like:

C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API_Simple\Build (path).vi or

C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API_Simple\Build (project reference).vi

There is a polymorphic container for those two called just "Build.vi" in the same folder.

 

If you wanted to modify the build spec, I'd start by looking at

C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API\EXE\Open EXE.vi

which provides an NI_AB_API_EXE.lvclass object, and can be manipulated to adjust build specification properties/fields.

 

Finding the right VIs can be a bit fiddly for this API, but browsing around the AppBuilder directory and looking at the connector pane for close-sounding names can be pretty effective.

I've used these to create a cross-platform PPL building system that I'm thinking about writing up.

 

 

 


GCentral
0 Kudos
Message 10 of 10
(3,459 Views)