09-27-2009 01:55 PM
I agree with the copy/paste issues, but I think the method is simple and effective and avoids the reference issue. The snippets/fragments are completely interchangable, and if you like you can use snippets when they work and fragments when they mess up. I have tossed around some ideas to add controls, fix up wires, etc., but decided it isn't worth the trouble (especially since my scripting experience consists of about an hour of experimentation). A slick UI (ie. keyboard shortcut) would make it very elegant. As soon as I learn to search for all objects of a given type inside a selection, I'll probably add a warning message when certain structures are included (broken wires, implicit references). Fixing (automatically) is hard, but identifying seems tractable.
All that has stopped me at LV8.6 is the availability of scripting (at least public availability).
I am working to add a 'Save for previous' option to the snippets I create in LV9 to make them automatically compatible with 8.6 (or earlier). I am still trying to decide on the feasibility of having multiple versions in a single fragment. Size limits of forum post images is the biggest consideration right now. As long as we remember the primary purpose of sharing/reusing small pieces of code, there shouldn't be a problem. My rule of thumb is that if the image is too large, you are probably trying to include too much code. (Large empty structures being a noticable exception).
Adding to the CCT would be great, the addition of a legitimate UI would be more than welcome. If the caveats are clearly documented, then I believe we will have an effective tool. If it stirs up enough interest, perhaps we'll get the inside help we need to make snippets work the way we would like. Operative word being work.
09-27-2009 03:32 PM
The very good news is I was able to create a snippet with the CCT in LabVIEW 7.0 that I could drop into LabVIEW 2009:
One of the options I was thinking about is a customizable header.
This header is:
$VERSION$ $DATE:%c$
$VERSION$ is replaced with the current LabVIEW version
$DATE:xxx$ is replaced by a timestamp with xxx as the timestamp formatter.
So you can add your own message.
Any more ideas?
Ton
09-27-2009 05:34 PM
For the LV8.6 users out there, here is a version for you. Use the 'Make Fragment' VI to make the fragment file. Run 'Fragment Helper' to go from the PNG file to LV code. In AutoHide mode, the window stays minimized in the task bar when an operation is complete. You can drag a file to the title bar in the task bar and the VI will Restore so you can drop the file in the path control. The rest is taken care of. You can select a New VI or the clipboard as the destination for the code. Once in the clipboard you can paste at will. No drag from web page yet, feel free to try to add that feature.
Not a lot of testing, so plenty of bugs for sure, but you can play around with code fragments. Probably could use a little more error checking, I check for a png extension, but not for code inside the file yet. Enjoy.
10-14-2009 10:31 AM
Darin -- I haven't had a chance to look at your MakeFragment code but I can contribute some code I think you guys (and girls) might find useful.
I've attached two zip files, both of which should be unzipped to your quick drop shortcuts folder <National Instruments>\LabVIEW 2009\resource\dialog\QuickDrop\plugins\
Once you have done this you will have two new quick drop shortcuts:
This is not official "NI" code -- just some VIs I wrote for my own personal use which I figured wouldn't hurt to share. As such the code is truly open source i.e. not supported, not guaranteed fit-for-function, but you are free to modify it. This code also hasn't been through much testing (I'm a product manager, not a developer - what time I can spend programming is generally not spent testing). Please keep the spirit of VI Snippet in mind as you are modifying the code -- namely a way for us to freely share LabVIEW code and ideas over the web.
Simon Hogg
LabVIEW Product Manager