LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String doesnt change the case structure

Solved!
Go to solution

Hi!

I have a problem with my string & case program.

 

I have 3 cases, but only the default one is working.

It doesnt matter if i type in something (1,2,3), nothing changes...

I also tried different names for the cases.

 

Do i have a mistake in the program?

I added the VI & picture.

 

Thanks a lot.

Download All
0 Kudos
Message 1 of 7
(1,094 Views)
Solution
Accepted by topic author kalle69

Your string seems to also contain a linefeed (or other invisible characters). Right-click your string control and select "limit to single line". See if this helps (sorry, cannot open your VI, only LV2020 here).

0 Kudos
Message 2 of 7
(1,090 Views)

@altenbach

thanks so much. works now!

 

but i dont get why it didnt work. 

I didnt insert any linefeeds, is this a common problem? 

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

Your picture (I also cannot open your VI -- next time, choose "Save for Previous Version" from the File menu and specify LabVIEW 2019 or 2021-- the "old-timers" don't constantly install the "latest versions") seems to show a Case structure with nothing wired to the "Selector" (looks like [?] on the left-hand edge).  Ordinarily, this would result in a "broken VI", but you include a "Default" case, so "unwired" means "always Default".

 

Wire something to the Selector, please.

 

Bob Schor

0 Kudos
Message 4 of 7
(1,063 Views)

my string "auswahl" is wired to the "?".

Isn't this correct? i thought thats enough, so i can type my options in the string and the case would change?

 

Sorry - im a noob.

0 Kudos
Message 5 of 7
(1,046 Views)

@kalle69 wrote:

I didnt insert any linefeeds, is this a common problem? 


Your string shows the overflow mark, so it seems to contain an extra linefeed. if the string is not set to "limit to single line", pressing [enter] will add a linefeed instead of ending the entry, so that's what probably happened. (For debugging, you could wire a "string length" and indicator to see how long the string really is)

 

You seem to deal with unit conversions, so having a string with a numeric value is confusing (first of all, if you really want numerics, use a numeric control, not a string but then the user needs to know what the numbers mean!). I would recommend an Enum with intuitive item names (e.g. "F to C", "C to F", "F to K", etc.). Now you are guaranteed to have a valid entry and you don't even need a default case. In addition, the cases are now named after the items to make the code readable and self-documenting.

 

altenbach_0-1688306106915.png

 

0 Kudos
Message 6 of 7
(1,037 Views)

@kalle69 wrote:

my string "auswahl" is wired to the "?".  Isn't this correct?


Yes, that would (generally) be correct, but from a picture of your code, where the wire from "auswahl" doesn't run straignt into the "?", but seems to run just into the side of the Case, is yet another reason to attach your VI in the form that it can be opened with a version of LabVIEW 2-3 years previous to the current release (so people like Altenbach and I can open it, and take a closer look at your code and "watch it run").

 

Never mind for now -- you seem to have this solved, but remember for next time, please.

 

Bob Schor

0 Kudos
Message 7 of 7
(985 Views)