Jump to content
Jacemdom

Get last array element VIM

Recommended Posts

Nice example of a VIM. I'm finding VIMs to be very useful. I think they be the best new LabVIEW feature since the event structure.

Share this post


Link to post
Share on other sites

There already is a primitive that does this.  The Delete From Array returns the last element in the array if nothing is wired to the length and index.  There was a thread on LAVA years ago about which was a faster method, and a few versions of LabVIEW the method you showed was faster, but in most the delete from array is faster.  And it already has a quick drop dfa.

  • Like 1

Share this post


Link to post
Share on other sites

It's a personal preference but I don't like using delete array for that purpose because I think it's confusing. I'm sure it costs me a few milliseconds when I see it and think "why would I want to delete an element from that array?" We want code that's easy to read not easy to write right?

Share this post


Link to post
Share on other sites

I get your point, and there is large amounts of debate over similar topics.  Should I not use Variable=Variable++ since not all developers know this is short hand for incrementing a variable?  To me the delete from array with nothing wired is used for getting the last element, but I get not everyone associates this function with that feature.

But I suppose if you really feel strongly about this you could make a VIM that just has this one primitive in it.

Share this post


Link to post
Share on other sites
On 12/7/2017 at 8:31 AM, hooovahh said:

There was a thread on LAVA years ago about which was a faster method, and a few versions of LabVIEW the method you showed was faster, but in most the delete from array is faster.  And it already has a quick drop dfa.

Thread in question.

Once the stomping was fixed in the Delete From Array (supposedly in 2014), that became a lot faster than any other method.

Edited by crossrulz

Share this post


Link to post
Share on other sites

A “last element” VIM would be clearer than using “delete”, as it could have an icon that suggests the last element   I use a “first and last element” VIM because I often need both to determine ranges.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.