LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"switch-case" in C/C++ to labview

Hi guys,

 

I want to define some constants like "Garry" = 2; "Leo" = 5; "Ray" = 110. And then use this string defines in a case structure. The switch/selector has to be an integer number.

 

0 Kudos
Message 1 of 7
(3,556 Views)

Hi JoVMo,

you can use a ring for it.

 

Mike

Message 2 of 7
(3,554 Views)

I found a typecast on an enum constant. But can u explain more bout the ring? What kind of ring?

0 Kudos
Message 3 of 7
(3,542 Views)

Hi JoVMo,

the ring constant is in the same palette as the enum.

 

Mike

0 Kudos
Message 4 of 7
(3,532 Views)

Ah ok, the enum has sequential values and the ring can use random values. 😉 got it

0 Kudos
Message 5 of 7
(3,522 Views)

Enum's cant have dispersed values in LV, they're always 0..X, with a Ring control you can set each option to hold a value.

Enum's on the other hand connect their names to a Case, in the case of the Ring the cases will be named 0..x.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(3,521 Views)

One other thing regarding rings and ENUMs. You can typedef an ENUM which means that all instances of it will be updated when the typedef is modified. You cannot do the same with a ring. You will need to programmatically initialize it and you will have to manually maintain all case structures that use it. If you change the strings in the ring the case structures are not automatically updated like an ENUM typedef. The ring will allow you to use non-sequential values but it does come with a cost of ease of maintenance.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 7
(3,503 Views)