02-23-2009 04:28 PM - edited 02-23-2009 04:29 PM
This nugget is the first in a series of nuggets on Case structures. Case structures have been around since LabVIEW 1.0. They are by far the most commonly-used block diagram object...there are more than twice as many Case Structures as there are For Loops (the 2nd most common object) in all the VIs in the shipping LabVIEW codebase. A Case structure can accept five different data types at its selector terminal: Boolean, Numeric, String, Enum, and Error cluster. Today's nugget will discuss the use of Boolean and Error selectors.
Boolean selector
The default data type of a Case Structure selector terminal (i.e. the type it has when you drop it on your diagram) is Boolean. Thus, a standard Case Structure has a True case and a False case:
Error selector
You can also wire an error cluster data type to the selector terminal. In this case, you will have an Error and a No Error case:
In this situation, the case structure is simply checking the value of the status boolean within the error cluster. So the following code snippets are equivalent:
As a general rule, if you are writing VIs that have error in/error out terminals, you should wrap the diagram code with an error case so the subVI code can skip execution on an incoming error. Most of the VIs that ship with LabVIEW use this technique. There is also a VI Analyzer Toolkit test called "Error Style" that ensures your diagram is wrapped with an error case if there are error terminals on the connector pane.
-D
P.S. - Check out past nuggets here.
02-23-2009 04:53 PM - edited 02-23-2009 04:55 PM
The Stop and Select nodes also accept the error cluster following the same logic.
They are by far the most commonly-used block diagram object...there are more than twice as many Case Structures as there are For Loops (the 2nd most common object) in all the VIs in the shipping LabVIEW codebase.
Very interesting... Would you come clean if there were a bunch of stacked sequences hiding behind those locked diagrams? 🙂
Aside - I've noticed you've turned off "Show dots at wire junctions". Any reason? (Am I not in the "club" if I thought "dots" were a great addtion a few releases ago?)
02-23-2009 06:16 PM
There are definitely some Stacked Sequence structures lurking in the LabVIEW codebase, although certainly not in any of the VIs I write. I just did a quick check of the LabVIEW 8.6 core codebase, and I'll just say that for every Stacked Sequence structure with 2 or more frames, there are roughly 150 Case structures. Do with that ratio what you will. 😉
As for dots at wire junctions, I think they're ugly. But I also think I'm in the minority with that opinion, so I'm probably the one who's not in the "club".
-D
02-24-2009 12:46 AM
I'm not keen on the Dots, but my real hate is those Iconize terminals on diagram. That's the first think I switch off along with making the labels transparent.
Regards
Ray Farmer
02-24-2009 04:10 AM
02-24-2009 05:11 AM
I personally like the dots and think they help to make the diagram clearer, and I also got used to the transparent labels after switching to 8.6. I don't like the terminals as icons, but I feel that NI is probably correct to have that as the default. In both cases, though, it's just a matter of personal taste. Since the setting is global, debating it is irrelevant.
Of course, I can't say the same about the undo. Most people probably have more need to be able to undo a lot than problems with the extra RAM this feature requires. Now, if only we had someone who was in the LabVIEW R&D department and who could push to change this default to a large number...
02-24-2009 06:16 AM
02-24-2009 08:10 AM
02-24-2009 08:29 AM
De gustibus non est disputandum!
I learned that phrase in high school Latin class, and it dates from the Romans. Roughly translated, it means "there is no disputing tastes." I think we have verified its veracity.
That said, I can chime in with my favorite changes:
02-24-2009 10:08 AM - edited 02-24-2009 10:13 AM
tst wrote:
Now, if only we had someone who was in the LabVIEW R&D department and who could push to change this default to a large number...
It would not be unreasonable to expect the default value of max undo steps to increase in a future LabVIEW version.
-D
P.S. - All this talk of LabVIEW preference settings is motivation for me to write my blog entry on my Tools > Options settings. Maybe I'll get it knocked out sometime this week.