cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in LAbVIEW coding

Highlighted
Ganny
Member

Doubt in LAbVIEW coding

Message contains an attachment

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

9 REPLIES 9
GerdW
Knight of NI

Re: Doubt in LAbVIEW coding

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… Smiley Very Happy

 

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! Smiley Wink

- 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
cbutcher
Trusted Enthusiast

Re: Doubt in LAbVIEW coding

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
Bob_Schor
Knight of NI

Re: Doubt in LAbVIEW coding

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

Ganny
Member

Re: Doubt in LAbVIEW coding

Hey GerdW, 

 

Thanks for the reply.

 

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

cbutcher
Trusted Enthusiast

Re: Doubt in LAbVIEW coding

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
Ganny
Member

Re: Doubt in LAbVIEW coding

Thanks. I'll work it out.

Ganny
Member

Re: Doubt in LAbVIEW coding

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

Thanks

Ganny
Member

Re: Doubt in LAbVIEW coding

I found it. 

GerdW
Knight of NI

Re: Doubt in LAbVIEW coding

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