LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

too many strings in a case selector

Hi,

 

I try to configure a case structure in a way that one case matches all the input strings started with "CurrentMeasurement" (and others.)

 

This results TRUE, if the input = "CurrentMt" and also TRUE if input = "Currenteasurement". But FALSE for "CurrentMeasuremen"


So what is the rule? In the help I find only hints for string ranges, for example stringe begin with a and b should be "a..c"

 

case.gif

 

But my basic problem is that I could have too many strings in the case selector label, so that they won´t be displayed completely, just a section of them. i.e the selector label contains 20 strings, all are 30 characters long. If you navigate with the mouse cursor to the selector label, a single line will be displayed, and all the strings not fitting on the screen, will be simply truncated.

 

regards

Mitulatbati

 

Mitulatbati

0 Kudos
Message 1 of 6
(2,910 Views)

Hi Mitulatbati,

 

some rules of thumb:

- use Enums for case selector issues

- use a "pre-stage" case structure: check for all those strings in a first case structure with only one string per case. The output of that structure then triggers the second case structure to make the "real" decisions...

- use StringMatching/StringParsing/RegEx functions to check for ranges of string inputs

Best regards,
GerdW


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

GerdW got there quicker than me, however I'd got as far as typing this lot out and attaching the vi, so I thought I'd post it. It is basically along the lines of GerdW's suggestions.

 

As far as I'm aware, the case structure won't do this level of string formatting for you (maybe its something for the idea exchange).

It might be easier to do the 'intelligence' before the case structure - i.e. pass your string into 'Match Pattern' to look for the phrase "CurrentMeasurement". If it is present, just pass "CurrentMeasurement" into the case structure.

See the attached.

 

That help?

 

Ian

0 Kudos
Message 3 of 6
(2,903 Views)

If you want to keep this in the case selector, use "CurrentMeasurement..CurrentMeasurement~" as your case.  The reason this will work and the "CurrentMeasurement.." you posted in the LabVIEW Minutiae thread doesn't is that "N.." searches for all ASCII characters above N.  Lower case ASCII is higher than upper case, which is why "Currenteasurement" and "CurrentMt" trips your case, but not mine.  The "~" is the highest value printable ASCII character, which is why it's on the end.

 

This is not 100% valid, if there is a "~" in the middle of your string it will not catch it.  You'll have to determine if that's an issue in your application.


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 4 of 6
(2,870 Views)

 


@_Ian_ wrote:

As far as I'm aware, the case structure won't do this level of string formatting for you (maybe its something for the idea exchange).

Ian


Do you mean like this one?

 



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
Message 5 of 6
(2,854 Views)

 


@Mark Yedinak wrote:

 

Do you mean like this one?

 


 

Well, there we go! Yep, thats what I meant. Though having read the discussions, I'm leaning back towards a pre-case structure check combined with the existing functionality... seems a lot safer!

 

Ian

0 Kudos
Message 6 of 6
(2,830 Views)