LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 11/20/2006

Over the past couple of weeks, I've noticed a few posts, both on the NI Discussion Forums and the LAVA Discussion Forums, where people were surprised to find some "hidden" menu or option.  I figured for this week's nugget I'd mention some of the more common difficult-to-find items in LabVIEW that I've seen over the years:
  • When using the Array to Cluster function, you must right-click on the function and choose "Cluster Size" and specify the size of the output cluster you wish to generate.  I've lost count of the number of times I've had to answer the question, "How come my output cluster only has 9 elements, even though my input array has [insert number not equal to 9 here] elements?"
  • The Read from Text File function in LabVIEW 8.0 and later has a right-click option called "Read Lines".  When you select that option, and you wire in a value to the "count" input, the function will return an array of strings, where each string is a line from the text file.
  • As jattas mentioned in last week's nugget, you can click and hold the "Step Out" debugging function to get a pop-up menu that displays the code path down to where the VI is currently paused, which allows you to step up to any level to continue execution.
  • I couldn't find the LAVA thread on this, but someone mentioned recently a similar click and hold technique to display the palette hierarchy when clicking the "Up" arrow on a pinned palette in LabVIEW 7.1 and earlier.
  • A lot of people aren't aware of this, but in LabVIEW 7.0 and later, if you right-click on a diagram object, one of the options in the right-click menu is to show a specific palette (usually the palette that contains that object or wire data type).  For example, if you right-click on the border of a While Loop, you'll see a "Structures Palette" option, which will display the Structures palette.  Similarly, if you right-click on an integer wire, you'll get a "Numeric Palette" option.  I've found that it's really hard for me to get into the habit of using these, but when I do, it's usually faster to get palette objects I need based on existing objects on my diagram, than starting from the top-level Programming palette every time I need to drop something.

This is all I can think of for now, although I'm sure there are others.  Feel free to post any other "hard to find" LabVIEW items that you've had to help people find in the past.

-D

P.S. - Check out past nuggets here.

 
Message 1 of 21
(11,295 Views)
"A lot of people aren't aware of this, but in LabVIEW 7.0 and later, if you right-click on a diagram object, one of the options in the right-click menu is to show a specific palette (usually the palette that contains that object or wire data type).  For example, if you right-click on the border of a While Loop, you'll see a "Structures Palette" option, which will display the Structures palette.  Similarly, if you right-click on an integer wire, you'll get a "Numeric Palette" option.  I've found that it's really hard for me to get into the habit of using these, but when I do, it's usually faster to get palette objects I need based on existing objects on my diagram, than starting from the top-level Programming palette every time I need to drop something."

Kudos on that last suggestion! I've been hoping that would make it into one of your nuggets. This saves me a LOT of time wiring things up on the diagram, especially with clusters. Right click on any cluster wire or cluster output terminal and you can browse directly to the cluster palette to drop down a bundle or unbundle by name. A bonus for doing it this way is that LabVIEW will automatically populate your bundle or unbundle with one of the items from the cluster you right clicked. So if you right click an error cluster and select Cluster & Variant Palette >> Unbundle by Name, you'll drop an Unbundle by Name with Status automatically populated in it. This doesn't seem to work if you're auto-indexing an array of clusters in a for loop, but in most cases it helps out.

This also helps out when right clicking refnums. Right click a queue refnum to go straight to the Queues palette, a file refnum to go to the file IO palette, etc.

Jarrod S.
National Instruments
Message 2 of 21
(11,247 Views)


@Darren wrote:
  • When using the Array to Cluster function, you must right-click on the function and choose "Cluster Size" and specify the size of the output cluster you wish to generate.  I've lost count of the number of times I've had to answer the question, "How come my output cluster only has 9 elements, even though my input array has [insert number not equal to 9 here] elements?"


Yes, one of the classics that has been around forever! I remember struggling with this in ~1996 😄

Of course since this is virtually a mandatory step ("...you must right-click on the function and choose "Cluster Size..."), maybe the cluster size dialog should popup automatically wenever such a node is placed or inserted. 😉

Message 3 of 21
(11,212 Views)


Of course since this is virtually a mandatory step ("...you must right-click on the function and choose "Cluster Size..."), maybe the cluster size dialog should popup automatically wenever such a node is placed or inserted.


I agree  ...  either that or make it a mandatory input.

- Brad

0 Kudos
Message 4 of 21
(11,207 Views)
When I first started using LabVIEW I remember also running into this problem.

I think one of the reasons it's such a problem is because so many functions will adapt to the input (think array functions for example).  From there, it's easy to make the assumtion that things will just "work", and thus miss the necessity to set this.

My question is, why does it not adapt to the exact number of cluster elements already?  (ahem, I am asking out of curiousity, not in a provocative manner)
0 Kudos
Message 5 of 21
(11,200 Views)

The number of elements in the array that is wired to the Array to Cluster function is dynamic, i.e. it could be anything at run-time.  Since the elements in a cluster are a part of its data type, and LabVIEW is a strictly-typed language, LabVIEW cannot compile a VI that contains a cluster with an unknown number of elements.  Thus, you must statically define the number of elements in the generated cluster at edit time.

And yes, we are aware of the difficulties regarding functions with these "hidden" configuration options, and we're looking into ways of addressing this issue in a future LabVIEW version.

-D

Message 6 of 21
(11,195 Views)


@Will.D wrote:
My question is, why does it not adapt to the exact number of cluster elements already?  (ahem, I am asking out of curiousity, not in a provocative manner)

"Cluster-to-array" sizes automatically, while "Array-to-cluster" cannot, for fundamental reasons.

Clusters have a fixed number of elements while the size of an array might not be known until the code executes. The array size might even vary during the run. Automatic determination of the required cluster size would only be possible if the array input size is fixed and known, e.g. if it is already folded into a constant. This is a rare case and it is probably not worth adding extra code to deal with it.

"Array-to-cluster" is not a very important function and is often abused to do things that are better done in a different way. If you look at posted code here, it seems popular for some reason to use "array-to-cluster" followed by "unbundle" to get the first few aray elements. This entire construct is better done with a properly resized "index array" node. 😉

Message 7 of 21
(11,181 Views)
The 'up'-arrow was in this thread (plug), and is also present in LV 8.x.
In short it look like this:


Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 8 of 21
(11,024 Views)
Thanks to both Darren and Christian for your explanations!

While this is probably something I should've deduced for myself, it's great to have meaningful explanations for the "why" about various LV functions!
0 Kudos
Message 9 of 21
(10,957 Views)
You know, half the fun is finding all these neat little popups that occur. I sometimes find myself randomly right-clicking or holding down the mouse button just to see if something pops up! Smiley Very Happy

In response to altenbach: I think the fundamental reason why you still see that is that, as you know, you didn't use to be able to use the Index Array function that way. So it was actually cleaner code to use the Array to Cluster and then the Unbundle rather than a bunch of Index Array functions especially when you knew what you were dealing with. Many people, including me, got into this habit and just forgot about it because it was just habit. Of course, as with all things we eventually learn better ways to do things when the language provides those techniques. Smiley Wink

I actually still find myself occasionally using the "Array to Cluster" function in very specific cases where it's the perfect function to use, so while not very important, it's still useful. Again, in very specific cases.
0 Kudos
Message 10 of 21
(10,888 Views)