LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
AristosQueue (NI)

On Case Structure, ""Add Case For Every Value" menu option should delete Default

Status: New

Wire a Case Structure with an enum. Now pop up on it and select "Add Case For Every Value." In today's LabVIEW, this adds new frames to the structure so that every enum value is handled by a unique frame. This makes creating the structure initially easy, and it gives you a way to walk through and make sure that you've filled in code for every frame. But today, the Case Structure has includes the "Default" case when the Case Structure is first wired. That is done so that wiring a Case Structure with an enum does not result in a broken VI. When a programmer provides a unique case for every value, the Default state is now redundant, and the only thing it does is create the potential for error if you ever add to the enum. Thus I would propose that if you use "Add Case For Every Value", then LV should remove the Default tag from the first case.

 

AddCaseForEveryValue.png

7 Comments
falkpl
Trusted Enthusiast

I have always not liked the default case on any enum, especially typdef enum for case structures (which they almost always are).  This makes maintaining and scaling programs hard since changing the enum will automatically assume the default action for the case structures.  I prefer the code to break and force me to fix the case structure.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
stbe
Active Participant

I also prefer to have a broken VI if I add another case into my Enums.

However, I opt for Kudos for "no Default case" at all.

_________________________
CLA
CrystalTech
Member

To stbe.  For an ENUM, I understand no Default (Kudos).  However, a Default case is absolutely necessary to handle general numbers and strings that don't match defined cases.

TCPlomp
Trusted Enthusiast

Related:

Changing a case structure from Boolean to String should remove the 'False' string from the 'Default' case structure.

 

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!
silmaril
Member

@CrystalTech: That's not entirely true. For numeric case selectors (which can only be integer types) you can also use value ranges, e.g. you could have the cases "..0", "1..5" and "6.." without a Default case.

 

gerh
Member

@CrystalTech: It is already possible to use enums without Default case, the issue is to remove it automatically if "Add Case For Every Value." is selected. Because of this +1 to AristosQueue. Indeed initially the Default case is necessary.

 

@stbe: In my opinion, "no default case at all" is a not so good idea: Except for booleans and enums it is common to have unhandled cases. Why? For beginners it could be a too big obstacle if any cas structure is generated without a default case, which leads to broken code. Also it isn't possible to guess any range of values to get a meaningful set of cases at insertion. So a better solution would be to remove the "Default" tag if Labview detects a full range. But because there is no useful trigger except a menu entry, the only applicable datatype is an enum. That leads directly to the idea of AristosQueue and/or to an additional menu entry "Make No Case Default", but that's a different story.

gerh
Member

@TCPlomp wrote:

Related: Changing a case structure from Boolean to String should remove the 'False' string from the 'Default' case structure.


This is an entirely different thread. But what is then with the "True" string? You don't come around to edit the strings by hand.