LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can Case Structures execute one particular set of code for multiple conditions?

Solved!
Go to solution

Event Structures can have a single Event case handle multiple Event Specifiers.

 

C code supports this kind of 'switch' statement:

 

switch(enumValue)
{
case A:
case B:
    handleAOrB();
    break;

case C:
case D:
case E:
    handleCOrDOrE();
    break;

default:
    handleOther();
}

 

How about Case Structures? Can I attach one code block to multiple enums values? (without duplicating the cases, which could be a maintenance nightmare)

 

Edit: The closest thing I found is http://forums.ni.com/t5/LabVIEW/case-structure-multiple-inputs/td-p/2377132, but converting my original enum into another one is somewhat unappealing

Certified LabVIEW Developer
0 Kudos
Message 1 of 4
(2,640 Views)
Solution
Accepted by topic author JKSH

You can specify multiple enum values for an individual case. Is this what you were looking for?

enumcase.png

 

For more information, check out the series of weekly nuggets I wrote on Case Structures: Part 1, Part 2, Part 3, Part 4, and Part 5.

Message 2 of 4
(2,630 Views)

That's exactly what I was looking for! Your Part 2 nugget held the key: I have to type in the comma-separated list manually. I was looking in the right-click menu but couldn't find anything, unlike with the Event Structure.

 

Thank you very much!

Certified LabVIEW Developer
0 Kudos
Message 3 of 4
(2,608 Views)
You can also enter a range with double dot, as 1..5
/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 4
(2,591 Views)