LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure / string as case selector / selector label contains parts of string

Hello,

 

I want to use a case structure with a string as case selector. My string contains different status informations.

 

Example of the status informations:

- Device id is 00. [possible values 00, 01, 10, 11]

- $18010053CC00FA0196200122015D [constans is "$", the HEX code varies]

- Mode is 00. [possible values 00, 01, 10, 11]

-...

 

I want use the case structure to switch between the different cases.

 

How can I choose the case selector, so that it switches between

- $ / Device id is / Mode is / ...

 

Thanks a lot and best regards,

Michael

0 Kudos
Message 1 of 5
(3,669 Views)

Hi Micha,

 


@MichaGue_01 wrote:

I want use the case structure to switch between the different cases.

How can I choose the case selector, so that it switches between

- $ / Device id is / Mode is / ...


You can create a case for each input string you want to handle. The case structure also allows to en-/disable case sensitivity for string inputs…

 

That being said: if you want to handle a big amount of different strings it would make sense to parse the strings before your case structure into a cluster of relevant information. In the case structure you can create different cases for e.g. your "mode" indicator and read the DeviceID from your cluster…

Best regards,
GerdW


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

The case itself is primitive. You can only switch based on ranges. This means > and = is used for comparison, even for strings. So, you can switch based on switch ranges, but that's it.

 

For you situation, you should be able to make 4 cases:

 

"Device id is 0".."Device id is @"

"$0".."$@"

"Mode is 0".."Mode is @"

Default

 

This defines ranges, for instance $0..$@ will match anything greater or equal to $0, and not greater or equal than $@. @ is the next character after 9.

 

Weirdly enough, for strings "0".."9" will not include 9. For numbers, it will. I'm sure there is a reason...

 

If you want more advanced switching, pre-process the string using match pattern or match regular expression (or anything really). That should result in either a string or an index. Use that in a case structure.

0 Kudos
Message 3 of 5
(3,640 Views)

Hi wiebe,

 


wiebe@CARYA wrote:

Weirdly enough, for strings "0".."9" will not include 9. For numbers, it will. I'm sure there is a reason...


As is written in the help🙂

Best regards,
GerdW


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

@GerdW wrote:

Hi wiebe,

 


wiebe@CARYA wrote:

Weirdly enough, for strings "0".."9" will not include 9. For numbers, it will. I'm sure there is a reason...


As is written in the help🙂


There's not much of a reason though.

 

I know it's not a bug, but definitely a cause of bugs 😉.

0 Kudos
Message 5 of 5
(3,627 Views)