LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Overwrite existing VI using scripting

Solved!
Go to solution
Highlighted

Overwrite existing VI using scripting

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
(3,873 Views)

Re: Overwrite existing VI using scripting

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
(2,379 Views)

Re: Overwrite existing VI using scripting

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

0 Kudos
Message 3 of 8
(2,380 Views)

Re: Overwrite existing VI using scripting

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
(2,380 Views)

Re: Overwrite existing VI using scripting

Try this...ScriptingOverwrite.png

0 Kudos
Message 5 of 8
(2,380 Views)

Re: Overwrite existing VI using scripting

Tried both suggestions and I still get the same error.

0 Kudos
Message 6 of 8
(2,380 Views)
This widget could not be displayed.
Solution
This widget could not be displayed.

Re: Overwrite existing VI using scripting

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.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 7 of 8
(2,380 Views)

Re: Overwrite existing VI using scripting

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
(2,380 Views)