From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite existing VI using scripting

Solved!
Go to solution

I am working on a VI scripting application. I want to be able to overwrite an existing VI with a new VI created from a template (so I want to be able to modify the template/the scripting source and regenerate the file). I get the following error when I save the vi:


"Error 1357 occurred at Invoke Node in Generate VI from template - overwrite.vi


Possible reason(s):

LabVIEW:  A LabVIEW file from that path already exists in memory, or exists within a project library already in memory.


Method Name: Save:Instrument"


I can open and modify the existing VI using scripting, and I tried opening the VI, and then copying and pasting the source code, but it is very difficult to get everything synced up properly when what I really want is a straight overwrite. I have attached the example project I have been working with. "Generate VI from template - overwrite.vi" in the Script Project directory is what I started with. Running that vi gives the error.

It may not be possible to do what I want so I would also welcome possible alternative solutions.

Thanks.

0 Kudos
Message 1 of 8
(8,363 Views)

Is it possible to delete the file first, then save?

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 2 of 8
(6,869 Views)

I tried deleting first but I still get the same error.

0 Kudos
Message 3 of 8
(6,870 Views)

Is it possible to do a "save as" on the original file, save the template as the correct name, then delete the original file?

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 4 of 8
(6,870 Views)

Try this...ScriptingOverwrite.png

Message 5 of 8
(6,870 Views)

Tried both suggestions and I still get the same error.

0 Kudos
Message 6 of 8
(6,870 Views)
Solution
Accepted by topic author LukeMSS

Your problem is that you are trying to overwrite a VI that is in the class.  And you can't edit anything in the class because it is open when you open the template.  What you need to do is save your Generated.vi to some temporary location, close it, and then use Move File to overwrite the "old" file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(6,870 Views)

Thank you so much crossrulz. That works perfectly. I knew there should be a simple way to do this.

0 Kudos
Message 8 of 8
(6,870 Views)