LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To Snippet or not to Snippet?

So this is a question followed by an odd project (on my quick-drop plugin spree... somebody stop me!).

 

What place do snippets have in people's day to day coding?

 

Personally, they exist in this strange limbo between "I'll code that myself every time", "That should be a common library object", "That needs to be a function", and "I would rather have that visible than hidding in a function". I have a handful of snippets sitting on my deskstop. Two notable ones are the "Coerce to Type" and a "Exit if runtime" (using the conditional disable).

 

Now, onto my strange project. Given the stange limbo state, I wanted to gauge snippet interest before posting this to the quick-drop group and spamming it even more. It creates a ghosted window that shows a snippet and follows your mouse. Scrolling the middle button will flip between snippets you have in a directory. Once you click, it places the snippet. Amusing bit of coding, but only useful if your coding method uses snippets currently.

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 1 of 14
(3,845 Views)

I guess my question is, why snippets? Why not subVIs in your user.lib directory? This is currently how I reuse common code like "Exit if Runtime", or "Val Change?".

 

Edit: I assume just to elminate another file you have to drag along with your source code?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 14
(3,840 Views)

I only use snippets for giving examples here on the forum.

 

For your exact scenario, make the VI and put it in your User.lib folder.  You can edit the palettes and have those items "Place VI Contents".  This is even easier if you use VIPM to make the package (which has a palette editor) and then you just install the package.  So what does this give you?  It basically works the same as a snippet (does not put down the VI itself, but the code inside of the VI) and you can make a normal quickdrop shortcut for it.

 

I do this specifically for my error clusters.  Yes, I am that picky on how they are spaced and everything.  So I have a VI with just two error clusters (error in and error out) that is sitting in my user.lib.  I set it to place the VI contents and created the shortcut of "ec".  So now I just open quick drop, type "ec", and then place the clusters down.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 14
(3,810 Views)

Place contents is the way I should do it. I just never get around to doing it.

I also hate placing actual (non-place-contents) VIs in my userlib unless they're managed by package manager and hosted somewhere. Tracking down dependencies annoys me to no end. However, going that route requires a good amount of work.

I didn't think snippets were used much and there is a reason I called this plugin odd. I did like the way you can see it while perusing.

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 4 of 14
(3,796 Views)

I only use Snippets for posting "viewable and executable" code on the Forums.  I don't think I'd ever consider using them in "real code".  Oh, another use I've made for Snippets is to "capture images" of LabVIEW code (while in LabVIEW) when I need a .PNG to insert into a document and I'm too lazy to bring up SnagIt.

 

Bob Schor

Message 5 of 14
(3,780 Views)

I agree with everyone else.  For me a snippet is only used on these forums.  Reuse if code is managed with packages and libraries, or in a catch all folder of reusable code that isn't ready for prime time.

0 Kudos
Message 6 of 14
(3,710 Views)

What ever happened to the "Moo" (Me Too) Button we all hated?

 

Snippets belong in the realm of technical corespondance NOT in replace a library of "Merge vis" or properly located Templates (Those wonderful File.New... objects)

 

So, They are GREAT for the forums or internal training documents that might also go to non-developers (e.g. I've often been asked to publish a Tip of The Week)  Some E-Mail managers (IT Weenies) know a *.vi is executable and block them but almost every filter lets *.png's through (Suckers don't tip 'em off) so they are absolutely invaluable for aiding the guy downstairs with his buggy code too!  BUT, Reuse? NO! Do the right thing and manage your "MyLabVIEW" and "TeamLabVIEW" tools with a policy agreed on within your team.  It will be worth the effort.


"Should be" isn't "Is" -Jay
Message 7 of 14
(3,684 Views)

@JW-JnJ wrote:

So this is a question followed by an odd project (on my quick-drop plugin spree... somebody stop me!).

 


Scripting projects often start with a sudden "Wouldn't it be really cool if?" then end after way more hours of development than you wanted to invest from my experience.

 

That being said, can you attach the decoder (chunck method).vi so I can try out the QD plugin?  Maybe it's me but I couldn't find it in the zip file you attached.

Matt J | National Instruments | CLA
Message 8 of 14
(3,663 Views)

@JÞB wrote:

BUT, Reuse? NO! Do the right thing and manage your "MyLabVIEW" and "TeamLabVIEW" tools with a policy agreed on within your team.  It will be worth the effort.


Don't get me wrong. I wasn't advocating this method. We are current in the process of working on a resuse library and slowly agreeing on what should go in (getting programmers to agree is hard)

 

That being said, there is a weird "no man's land" of reuse code. Some code is a combination of the following

  • Doesn't get used enough to necessitate getting placed in a resuse library. These typically get forgotten.
  • Are "place contents" and hard to recognize from a name/icon
  • Better documented by not being a SubVI (rare case)

This is the kind of code that usually involves a hunt down VI memory lane, examples, and copy/pasting bits. Mainly because you recognize it by function and connections, not by representation (icon/name). Maybe it's just me, but the larger/rare code collections could do better by a more visual representation. Not this though.

 


@Jacobson-ni wrote:

 

Scripting projects often start with a sudden "Wouldn't it be really cool if?" then end after way more hours of development than you wanted to invest from my experience.

That being said, can you attach the decoder (chunck method).vi so I can try out the QD plugin?  Maybe it's me but I couldn't find it in the zip file you attached.


 Totally agree. It was more of a learning experience and didn't take long. Waaay less time than the EasyConvert. This likely ends my adventure into plugins.

 

Yes, I'll get it uploaded tomorrow. I think that was part of someone else's quick-drop snippet plugin that I accredited in the placement VI. It was password protected so I thought it was a built-in function (dependencies!!!). I still think it's an interesting (and yes flawed) concept.

 

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 9 of 14
(3,646 Views)

@Jacobson-ni wrote:
That being said, can you attach the decoder (chunck method).vi so I can try out the QD plugin?  Maybe it's me but I couldn't find it in the zip file you attached.

Here.

Josh
Software is never really finished, it's just an acceptable level of broken
Message 10 of 14
(3,557 Views)