annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

"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
Messaggio 1 di 7
3.854Visualizzazioni

Hi JoVMo,

you can use a ring for it.

 

Mike

Messaggio 2 di 7
3.852Visualizzazioni

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

0 Kudos
Messaggio 3 di 7
3.840Visualizzazioni

Hi JoVMo,

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

 

Mike

0 Kudos
Messaggio 4 di 7
3.830Visualizzazioni

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

0 Kudos
Messaggio 5 di 7
3.820Visualizzazioni

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
Messaggio 6 di 7
3.819Visualizzazioni

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
Messaggio 7 di 7
3.801Visualizzazioni