nikko wrote: ↑March 2nd, 2021, 2:58 pm
is something like this possibile?
Code: Select all
[Variables]
Signs=XYZ
Count=2
[msSigns]
Measure=String
String=#Signs#
IfMatch=X & #Count#=2
IfMatchAction=[!SetVariable Meter1 "1"][!WriteKeyValue Variables Meter1 "1" "#@#Vars.inc"]
IfNotMatchAction=[!SetVariable Meter1 "0"][!WriteKeyValue Variables Meter1 "0" "#@#Vars.inc"]
IfMatch2=X & #Count#=5
IfMatchAction2=[!SetVariable Meter2 "1"][!WriteKeyValue Variables Meter2 "1" "#@#Vars.inc"]
IfNotMatchAction2=[!SetVariable Meter2 "0"][!WriteKeyValue Variables Meter2 "0" "#@#Vars.inc"]
IfMatch3=Z & #Count#=21
IfMatchAction3=[!SetVariable Meter3 "1"][!WriteKeyValue Variables Meter3 "1" "#@#Vars.inc"]
IfNotMatchAction3=[!SetVariable Meter3 "0"][!WriteKeyValue Variables Meter3 "0" "#@#Vars.inc"]
DynamicVariables=1
Like this:
Code: Select all
[MeasureExample]
Measure=String
String=#Signs# #Count#
IfMatch=^.*X.*\s2$
IfMatchAction=[!Log "X and 2"]
IfNotMatchAction=[!Log "NOT X and 2"]
IfMatch2=^.*X.*\s5$
IfMatchAction2=[!Log "X and 5"]
IfNotMatchAction2=[!Log "NOT X and 5"]
IfMatch3=^.*Z.*\s21$
IfMatchAction3=[!Log "Z and 21"]
IfNotMatchAction3=[!Log "NOT Z and 21"]
DynamicVariables=1
IfMatch only works on the value of the measure it is contained in, and is always a string regular expression. It has no ability to either look at any external value like a #Variable#, nor does it have any ability to do any kind of "equal/less/greater" numeric comparison. IfMatch is NEVER about "is equal to or less than" or anything like that. It is only about "is there a match between the string value of the measure and my regular expression?". It's not about "equal to", but rather "contains".
So what I did was combine the two #Variables# into the one String value of the measure, using a space to separate them. Then I can use a regular expression that looks for X or Y or Z or whatever in the first bit, followed by a space and then look for the numeric value as a string.
So:
IfMatch3=^.*Z.*\s21$
Start at the
^ beginning of the string, then look for a
Z with
.* zero or more of any characters before and after it, then a
\s whitespace character, followed by the numeric string
21, then the
$ end of the string.
If you might have spaces in the string variable, then you probably want to use something to separate the two other than a space. Try not to use a reserved character in regular expression, as that just complicates things. Maybe use a
; or
: character.