LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case structure selector label string wildcard?

Is there a wildcard for the case structure when attempting to define the selector label to choose amongst strings?

What I have are strings that could begin with a variety of different characters, but a few characters inside will be identical.  i.e.
MFC#c, T#c, P#c, so that the "#c" is the identical portion shared across cases

I've attempted using regular expressions, but they do not seem to be supported

thanks
James
0 Kudos
Message 1 of 7
(9,841 Views)
Regular expressions are not supported. Don't know if this has changed for 8.5. What you can do is to preprocess the string rather than driving the case structure directly. For example, you can use the Match Pattern function and use one of its output to drive the case structure. Or, one of the other string functions to basically map your strings to values that you can enter in the case structure element selector.
0 Kudos
Message 2 of 7
(9,832 Views)
oh thanks, that is easy enough, should have thought of it...
i'm using 7.1.1... still it'd be nice if they did just go ahead and support it in the selector label.
has it been suggested?
0 Kudos
Message 3 of 7
(9,824 Views)
here is what I came up with
0 Kudos
Message 4 of 7
(9,817 Views)
That will be hard to implement, and the result will probably not be
desirable.

What if multiple cases match? This is not possible in the current
implementation (broken arrow), but it would be impossible to guess at
compile time if two regular expressions will match the input string.

Also, it will be slow. With the current case, a few compares can deside
which case to select. One compare could rule out half the cases. With
regular expressions, each expression has to be executed untill a match is
found.

And when a match is found, you'd probably want to get the resulting match,
and everything before and after the match. So you need to get that out of
the case. Something like how you get the data from an event out of the event
structure.

Seems like a lot of work and trouble to have something that can be
programmed easilly.

Simple wildcards might be doable though. Like ".a." will match every tla
with an a in the middle. Still, that is simple to program yourself.

Regards,

Wiebe.


Message 5 of 7
(9,795 Views)

Although you cant do regular expressions there are a few things you can do. 

1. Use a regular expression parsing engine which returns an enum (the name of a lexical class) and pass the enum to the case structure.

2.  Use multiple strings in a case "a', "b", "c" will handle a or b or c

3.  use string ranges.  a* is the same as "a"... "a~".  I use the tilda because it is a very high ascii value ascii character and will cover all printable ascii characters.

 

Be careful when you attempt this because it is very easy for strings to slip through your parser and execute the incorrect case if you dont do your regexps right.

 

Paul

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 6 of 7
(9,786 Views)
jccorreau1 said:

i'm using 7.1.1... still it'd be nice if they did just go ahead and support it in the selector label.
has it been suggested?


It has, as this has come up before. Still, it wouldn't hurt to provide an additional request (link to suggestion center provided in thread I mentioned). The more people ask for something, the more likely it is to be implemented, if it's not too difficult to do.
0 Kudos
Message 7 of 7
(9,768 Views)