LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify an lvproj file in LabVIEW?

Solved!
Go to solution

Hi all,

 

I have a complex project with a number of build specifications.  Each of those build specs has the version number in it in several places.  Opening each build spec takes a looooong time for LV to process, so the chore of bumping version numbers on this project is a major pain.

 

This works:

  • close the project
  • open the .lvproj file in Notepad++
  • search and replace as necessary
  • save the file
  • open the project in LV

I just wrote an LV script to do some other pre-build stuff and when I try to code the search and replace in labview (with read from and write to text file), the project file won't open because it's corrupt.

 

I'm guessing this is a unicode issue, but I don't know how to fix it.  Any tips?

-Barrett
CLD
0 Kudos
Message 1 of 9
(7,254 Views)

I would suggest attacking the lvproj file using the XML DOM as opposed to a String based search and replace.  I have used them extensively to alter various LV generated XML files with mostly good results.  I miss the regexes, but XPath is almost as much fun.

0 Kudos
Message 2 of 9
(7,247 Views)
Solution
Accepted by topic author blawson

Is the XML still valid? I think you can tell by opening it up in Internet Explorer. Just make a copy of your .lvproj with the extension .xml and do a file/open from Internet Explorer.

 

How are you doing the "search and replace" in LabVIEW? Are you using the xml functions?

=====================
LabVIEW 2012


Message 3 of 9
(7,246 Views)

Hah! Thanks for prodding me to look at the output file more closely, Steve. Turns out I was appending the new text to the end of the file rather than rewriting the file.  D'OH!

 

So for the record: you can open, write, and close an lvproj file with the text file primitives just fine, at least in LV2010 sp1.

-Barrett
CLD
0 Kudos
Message 4 of 9
(7,223 Views)

lvproj files can contain binary parts, such as icons, so be careful.

0 Kudos
Message 5 of 9
(7,190 Views)

In what circumstances would that be the case?  I have icons included in the project (for the build specs) but that's just a path to a file...

 

I check the project file into source control first, so if this script breaks it I can easily revert it (that's step 1!)

 

-B

-Barrett
CLD
0 Kudos
Message 6 of 9
(7,177 Views)

I don't know all the circumstances that could lead to binary parts in an lvproj file, and it may not exist any more (I ran into it in LabVIEW 8.6).  As long as you are not modifying those parts, you should be OK.  You just have to make sure your text/XML parser can handle non-ASCII blobs, since you may have to rewrite them if you are adding information before them.  Streaming the parts I was relocating as U8 arrays instead of text eliminated any problem.  Note that U8 Array ↔ string conversion is an in-place operation, so you can go between the two easily enough with no major performance penalty.

Message 7 of 9
(7,160 Views)

If you want to alter a project file directly, you should use the methods that LV provides - then you don't have to worry about all this other stuff. There is an Application method for returning a reference to an existing project or creating a new one. You can modify things programatically using such a reference.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 8 of 9
(7,152 Views)

@mikeporter wrote:

If you want to alter a project file directly, you should use the methods that LV provides - then you don't have to worry about all this other stuff. There is an Application method for returning a reference to an existing project or creating a new one. You can modify things programatically using such a reference.

 

Mike...



That's a nice idea, but it doesn't do what I'm trying to do, at least in 2010 and prior. I'm (mainly) trying to bump version numbers in build specifications.  The relevant classes in VI server don't have properties or methods that do much, and the App Builder API doesn't do installers and cannot retrieve version numbers from a buildspec.

 

background and limitations of AB API discussed here:

http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-02-15-2010/

 

text search works fine, is fast, is easy.

-Barrett
CLD
0 Kudos
Message 9 of 9
(7,131 Views)