09-18-2009 09:52 AM - edited 09-18-2009 09:54 AM
Here is one for the early adopters of LV2009, the "Code Snippet". I have been using LV2009 for less than a week and these things are really starting to grow on me, and given their potential for improving the quality of life on this forum I thought it would be a nice subject to discuss. It really is pretty simple, just select some code, create a code snippet and you have something like this.
A few things I have noticed in my short experimentations. First, the VI must be saved first. I think this is a bit of a drag, sometimes I would try to make a quick example to answer a question without really needing to keep the VI. I have learned to live with it. Second, no keyboard shortcut by default, this was quickly remedied and is now Shift-Ctrl-C on my computer. Finally, I was trying to use these to collect bits of code that I reuse frequently, but I missed the ability to label the VI from which they came. If you look closely at the above snippet, you'll see that I have remedied this as well. I have attached some code I threw together to add a text label to a snippet file. Hopefully it is useful in case you don't want to wait for SP1.
I have seen a few issues (browsers, references being changed, etc.) being discussed, any other gotchas lurking? For a first implementation it seems to be quite workable with some room for improvement.
For help, check out this site:
http://zone.ni.com/devzone/cda/tut/p/id/9330
VIOTD groundrules here.
09-18-2009 10:23 AM - edited 09-18-2009 10:26 AM
One thing I have noticed (which makes perfect sense and it wouldn't work any other way) and may catch you off-guard is:
09-18-2009 12:49 PM
For some amusement on your Friday afternoon you can check out a less practical code snippet implementation here.
http://forums.ni.com/ni/board/message?board.id=BreakPoint&thread.id=8610
09-18-2009 02:16 PM
Firefox browser doesn't support snippets natively. You need to get the IE Tab extension. This runs IE code in your Firefox tab and makes the drag and drop work.
Bill
09-18-2009 02:22 PM
Darin.K wrote:Here is one for the early adopters of LV2009, the "Code Snippet". I have been using LV2009 for less than a week and these things are really starting to grow on me, and given their potential for improving the quality of life on this forum ...
When theyt demoed this for the LV Champions, I felt the same way. I was hot on using them until I realized most everything invloving a proprty node did not work right and I was confusing noobs by posting non-functional code.
But when that issue gets fixed, oh boy!
Ben
09-18-2009 03:46 PM
Broken Arrow wrote:One thing I have noticed (which makes perfect sense and it wouldn't work any other way) and may catch you off-guard is:
- the Snippet will convert your property nodes to strict and put a reference to it.... also note that my "false" constant got hidden by the big strict node !
. You'd have to move the constant over quite a bit to prevent that.
Message Edited by Broken Arrow on 09-18-2009 10:26 AM
I have to play straightman here, why does this make perfect sense for a snippet? Does it actually work? If there is a fundamental reason why this construct won't play nice with a snippet, I would prefer it if it would give me a plain screenshot and a warning that no code is attached to the snippet. At least I have a screenshot that shows my intentions.
09-18-2009 08:00 PM
Darin.K wrote:
Broken Arrow wrote:One thing I have noticed (which makes perfect sense and it wouldn't work any other way) and may catch you off-guard is:
- the Snippet will convert your property nodes to strict and put a reference to it.... also note that my "false" constant got hidden by the big strict node !
. You'd have to move the constant over quite a bit to prevent that.
Message Edited by Broken Arrow on 09-18-2009 10:26 AM
I have to play straightman here, why does this make perfect sense for a snippet?
Because the Snippet is a VI. If you select that code on the right and tell LabVIEW to create VI, it would do the same thing (make a strict ref). Maybe it doesn't make "perfect" sense, but it is logical.
09-18-2009 08:08 PM
09-20-2009 12:04 PM
Just to be clear - a snippet is NOT a VI. It is LabVIEW code embedded into a PNG file. Unlike a VI, it does not include a front panel or executable code, just the block diagram. I can't say that I see why this should make the generated code use a reference and I'm assuming it's just an oversight/bug.
09-20-2009 01:29 PM - edited 09-20-2009 01:30 PM
tst wrote:Just to be clear - a snippet is NOT a VI. It is LabVIEW code embedded into a PNG file. Unlike a VI, it does not include a front panel or executable code, just the block diagram. I can't say that I see why this should make the generated code use a reference and I'm assuming it's just an oversight/bug.
Right. Since it doesn't have front panel code, it makes references. And again, I'm on board with not liking it - just trying to make sense of it.