Wednesday, January 28, 2009

Captions

Last week I was fixing a problem with a VI where the wrong text was shown in the Context Help window for some of the controls. Perhaps it's a VI you recognize...

Yes, embarrassingly enough, it was a bug with my Getting Started window. The small images to the left of some of the links are picture rings. They were showing their decidedly unhelpful labels in the help window:
After deciding that the picture rings should simply have the same names and descriptions as the items to their right, I added a property node to set the caption text and description.

Then I ran the VI. It didn't work. In fact, it fixed the context help for some, but not all, of the picture rings.

You might already be able to spot what I did wrong. If not, maybe you'll be able to guess after I explain more about captions.

What Are Captions?

When you place a control on a VI's front panel, it has a label where you give it a name. This name is shown in the context help window. It also provides the identifier for programmatic interfaces such as Set Control Value.

When the LabVIEW team added features to support localization of VIs, we needed to be able to change the name of a control. But if we changed the label, calls to interfaces like Set Control Value would break. So we introduced another kind of label, called a caption.

We also didn't want to make VIs bigger (in memory and on disk) by adding a part to every control and indicator that most wouldn't use, so captions are "lazily created." When you right-click on a control and select Visible Items>Caption, LabVIEW creates a caption for the control. It also hides the label (since you usually use a caption instead of a label, not in addition to it) which leads to the confusing situation where the menu option appears to have no effect (because the caption initially looks exactly like the label and is in the same location).

You can tell that a control has a caption by looking at the context help window. When the VI is in edit mode, the context help displays the caption and the label, with the label in square brackets. (Note that when the VI is running, the context help displays the caption but not the label).

Fixing the Bug

Coming back to my original story, when I checked the error out of the property node that was setting the ring caption, I found it was generating error 1320: "In run mode, LabVIEW cannot get or set a property for a control part that has not been created."

The problem was that some, but not all, of the rings had caption parts. As I mentioned earlier, captions are lazily created - you can't set the text on them if they don't exist, and LabVIEW can't create them on running VIs. The solution was to show (and thus create) the captions for all the rings. Luckily, I was using LabVIEW 8.6 and could use the new multi-select feature. I selected all the rings, right-clicked to show the Properties dialog and showed all their captions in one step. Problem solved.

Thursday, January 08, 2009

Learning LabVIEW

A LabVIEW user who is aspiring to become a CLAD (Certified LabVIEW Associate Developer) asked me for book recommendations. I didn't know the answer, but I knew who to ask. My colleague Nitin Thomas, one of our LabVIEW Product Support Engineers, helped me out with the following links, which I think would be helpful to anyone trying to learn LabVIEW:

Monday, January 05, 2009

New Blog from Darren of LabVIEW R&D

I'm thrilled that Darren Nattinger (of Darren's Weekly Nugget fame), creator of the Quick Drop feature of LabVIEW, has started his own blog: LabVIEW Artisan

Darren is one of the top experts in VI development here at NI, and I am looking forward to reading his development tips and ideas for future features!