LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to write a VI that can modify and save another VI?

In the attached VI, I open a reference to another VI, and would like to be able to change the labels for various controls and indicators and then save the VI I oppened. Is there any way to do this? Other random comments if you see I'm doing something else wrong in terms of good labview programming.

thanks,
Bjorn
0 Kudos
Message 1 of 5
(2,290 Views)
Yes!

You almost had it.

Watch the VI Hiarchy screen when you execute your code in execution highlihgting mode.

You will see that you VI is being unloaded before the chages are made.

I have modified your code, see attached.

The big difference is I have added a shift register that caches the VI refnum. THis keeps the VI in mememory once it is loaded.

I removed the close VI refrernce from the load event.

Moved the read from controls into the event that use them and added one local to make up the difference.

I alos added an explicit save event to save the VI. This works as long as nobody else is using it.

If you really want to have fun, try adding an additional load to your program and add a typedef to the FP of the "VICTUM.VI".

By renaming typedefs and control load order, you can re-define the objects on the FP of VI's.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(2,282 Views)
Thanks for the reply ben,

unfortunately, your modified version doesn't work any better for me, I load a VI, hit apply, then save, but it doesn't appear to save it. I also tried entering a new filename before hitting save, which I expected should create a new file with a modified copy of the VI I loaded, but no such file is created 😞

How does one get the "VI Hiarchy screen" btw? I'm not sure what you mean by your last comment, but it sounds tricky beyond what I should need to do 😄

Bjorn
0 Kudos
Message 3 of 5
(2,276 Views)
I was closing the VI refnum in the "apply" case!

I changed this.

1) Load VI
2) Apply
3) Save

The Hierarchy screen can be found at

Browse >>> Show VI Hierarchy

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 5
(2,259 Views)
Cool, it works great, thanks!
0 Kudos
Message 5 of 5
(2,224 Views)