Popular Post Sparkette Posted August 18, 2015 Popular Post Report Share Posted August 18, 2015 Warning: This shouldn't come as a surprise given the title of the thread (as well as who's posting it) but this is NOT officially supported by NI. Don't use this for anything you don't want to break! I ran a VI that recursively opened every VI in the LabVIEW installation directory and scanned it for Call Library nodes, then saved anything it found to a spreadsheet. And guess what it found in the palette API? Functions that open and save "resource" files, which happen to be the way VI files are internally stored, as well as some other LabVIEW files. It lets you manipulate the internal resources as an array of clusters. Now in case you didn't already know, the front panel and block diagram are stored as binary resources (known as "heaps") in this file, and these functions can't parse that format. So it's not too useful, right? Wrong. Does this dialog look familiar to anyone? That's the hidden internal settings dialog, known for some reason as Ned. To access it, add LVdebugKeys=True to your LabVIEW.ini file and restart LabVIEW if it's already running. Now hold Control+Shift and press D, N. You have to press the keys relatively quickly for it to work. (You can press D, H instead to open Heap Peek, which lets you view the internal representation of objects, as well as their exact location in memory--think about how the latter might be useful!) Now do you see that option I have selected? "Heap Save Format (Binary2)". Click that a few times, and you'll see one of the options is XML. Yep, it turns out LabVIEW has a hidden XML-based VI format. It even opens just fine with the heap save format set to the default. Keep in mind only the heaps are saved in this format; the rest of the file is still binary. But that format can be parsed by those library functions I found. Unfortunately, it seems the block diagram has some sort of checksum and the VI won't load if that's wrong. I know this because after making a simple change to the XML (changing the block diagram's background color) it didn't load, and there was a a 16-byte section in the file that was changed with seemingly-random data. I suspect that this is MD5, considering that seems to be the standard LabVIEW uses, but I tried calculating the MD5 hash of certain parts of the file and it didn't seem to match. Here's two VI's that you can use to turn resource files (like VI files) into resource cluster arrays, and vice versa. Load Resource File.vi Save Resource File.vi And here's a VI that will automatically set the heap save format to XML (using the private method "Application.Call Internal Command"), save a VI (from a refnum), and then put the heap save format back to what it was before. So it basically just saves a VI in the XML format. Save VI with XML Heaps.vi 3 Quote Link to comment
hooovahh Posted August 18, 2015 Report Share Posted August 18, 2015 The Load and Save resources is a relatively well known function, and was recently discussed in a thread where a user was looking for a way to detect if a block diagram existed, when looking at the VI contents within an EXE. https://lavag.org/topic/19068-does-vi-have-block-diagram-at-runtime/#entry114822 In that case the detection method was to look for the BDHb, BDHx, BDHc, or BDHP blocks. My method in that VI was to parse the binary file itself pulling out the block. I posted that code, or similar code in a thread, with you some time last year. The Ned window and XML is a little less known, for several reasons. I discovered it myself by going through the list of keyboard shortcuts. I read up about the heap peak window (CTRL+SHIFT+D, CTRL+SHIFT+H), then I saw there was a window command (CTRL+SHIFT+D, CTRL+SHIFT+W). I figured this meant Debug, and Window and Debug and Heap Peak, so I went through the whole keyboard looking for new shortcuts, low and behold D, N was the ned window. As you can imagine saving in XML is an incomplete function. It might work for simple VIs, but I'm guessing not all VI types are supported. Things like VIs in libraries, ability VIs, and other things might not be supported. When I talk to other LabVIEW guru's and I want to blow their mind with features that they didn't know existed in LabVIEW, talking about VI password protection, and saving in XML are the topics I usually go to. Now that more people know about these things I need to continue to research other topics. That being said you did teach me something new today, and that is the ability to set and get Ned settings using VI Server, that is some very cool stuff and could come in handy. Quote Link to comment
Sparkette Posted August 19, 2015 Author Report Share Posted August 19, 2015 Okay, now I have something a bit lot better for you. I made a GUI that lets you edit resources. Plus it can automatically load VI's as XML. And you know what else? It even fixes that checksum. (Turns out Thomas Zeugner, the VI Explorer guy, already figured it out, and posted a description on his website.) I've posted it here. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.