LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in LAbVIEW coding

Errors:
Case Structure: Selector values have wrong type
Case Structure: No case for some selector values

 

I'm getting these errors when I changed the name of the case structure from "True" to user-defined.

Any help is appreciated. Thanks

0 Kudos
Message 1 of 10
(3,425 Views)

Hi Ganny,

 

I'm getting these errors when I changed the name of the case structure from "True" to user-defined. Any help is appreciated.

Easy solution: revert from your "user-defined" case label and write "True" again… 😄

 

Better solution: replace the "case selector" boolean by an Enum control with two items. Wire this item to the case selctor input…

 

Other things:

- Mr. Fahrenheit has one more h in its name! 😉

- NOT(x XOR FALSE) is the same as a simple NOT(x)

- you even don't need the NOT when you just change the colors of the LED indicator…

- using AutoCleanup from time to time would be nice…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,401 Views)

Your case structure's selector (if that's what the green question mark is called) is wired to a boolean control. Booleans only have the values true or false, so those are the cases that must be handled.

 

If you want to use a string control, you can do that instead - then Fahrenheit and Celsius will work. However, in that case, you'll need to specify one of the cases as default, because it's impossible to specify every possible value of a string. 

 

Alternatively, you might want to consider an enum. These are controls which take a numeric value from a specified list. Since you can list every possible value, you don't have to give a default (by default! You can change the options to make this not true...) but the case structure displays the string value of the enum, which is also part of the type.

 

A radio button might also work for you - these are a graphical wrapper around enums. 


GCentral
0 Kudos
Message 3 of 10
(3,397 Views)

You don't get to define the Language!  Case statements are common in many computer systems, and they all have the same general form.  There is a "Case Selector", meaning something that can take on a finite (and usually limited) set of values, then code to handle what happens for each possible value of the Selector.

 

In your case, the Selector is a Boolean,  "Case Selector", which can take on only two values, Boolean True and Boolean False (I write "Boolean" because the values must be the same Type as the Selector).  It makes no sense to say "Is Case Selector, which can only be Boolean "True", equal to the string "Fahrenheit".  LabVIEW has generated some Error Messages that say exactly this (but without the longer explanation I've given).

 

Read the Help for the Case Structure.  Learn LabVIEW.  Spend time with the "Getting Started with LabVIEW" material on the first page of the LabVIEW Forums.

 

Bob Schor

0 Kudos
Message 4 of 10
(3,395 Views)

Hey GerdW, 

 

Thanks for the reply.

 

Where can I find Enum control? What is AutoCleanup and where do I find it?

0 Kudos
Message 5 of 10
(3,388 Views)

Enum controls are in the "Ring and Enum" palette.

 

Autocleanup is the brush icon on the block diagram toolbar, the keyboard shortcut (at least by default) is Ctrl-U.


GCentral
0 Kudos
Message 6 of 10
(3,380 Views)

Thanks. I'll work it out.

0 Kudos
Message 7 of 10
(3,376 Views)

I'm not able to find "Ring and Enum" Palette. Where exactly can I find it?

Thanks

0 Kudos
Message 8 of 10
(3,354 Views)

I found it. 

0 Kudos
Message 9 of 10
(3,350 Views)

Hi Ganny,

 

Right-click the frontpanel of a VI to open the palettes: choose Ring&Enum…

 

Maybe you should take the free online courses for LabVIEW beginners? They are offered in the header section of the LabVIEW board!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(3,348 Views)