04-14-2020 02:04 AM
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
04-14-2020 02:18 AM
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…
04-14-2020 02:54 AM
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.
04-14-2020 03:03 AM
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… 🙂
04-14-2020 03:07 AM
@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 😉.