It is currently March 28th, 2024, 1:52 pm

Understanding Ifmatch

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Understanding Ifmatch

Post by balala »

SilverAzide wrote: December 10th, 2020, 5:03 pm IfMatch matches exactly (the way you have it written), so since "XYZ" isn't exactly "X", "Y", or "Z", then all the "not" matches will fire.
No, in fact exactly contrary: all IfMatches are true. If in the IfMatch option is posted a literally expression, it is true if the used expression is present into the checked string.
For instance:

Code: Select all

[Variables]
Signs=XYZ

[msSigns]
Measure=String
String=#Signs#
IfMatch=X
IfMatchAction=[!ShowMeter "mtSign1"][!UpdateMeter "mtSign1"][!SetVariable One "True"]
IfNotMatchAction=[!HideMeter "mtSign1"][!UpdateMeter "mtSign1"][!SetVariable One "False"]
IfMatch2=Y
IfMatchAction2=[!ShowMeter "mtSign2"][!UpdateMeter "mtSign2"][!SetVariable Two "True"]
IfNotMatchAction2=[!HideMeter "mtSign2"][!UpdateMeter "mtSign2"][!SetVariable Two "False"]
IfMatch3=Z
IfMatchAction3=[!ShowMeter "mtSign3"][!UpdateMeter "mtSign3"][!SetVariable Three "True"]
IfNotMatchAction3=[!HideMeter "mtSign3"][!UpdateMeter "mtSign3"][!SetVariable Three "False"]
DynamicVariables=1

[mtSign1]
...

[mtSign2]
...

[mtSign3]
...

[MeterResult]
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=One: #One##CRLF#Two: #Two##CRLF#three: #Three#
DynamicVariables=1
As you can see the One, Two and Three variables are returning which IfMatch is true and which one is false. All are true in the above code. If you modify the Signs variable for instance to Signs=XAZ, One and Three are still true, but Two becomes false, because X and Z are still present into the expression, while Y isn't anymore.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: Understanding Ifmatch

Post by SilverAzide »

balala wrote: December 10th, 2020, 6:37 pm No, in fact exactly contrary: all IfMatches are true. If in the IfMatch option is posted a literally expression, it is true if the used expression is present into the checked string.
Huh... I guess I misunderstood the manual examples. The manual implies the opposite (at least as I read it). So the example that illustrates matching, like: IfMatch=.*Green.*, would also return true if the expression was simply IfMatch=Green? :?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Understanding Ifmatch

Post by jsmorley »

SilverAzide wrote: December 10th, 2020, 10:37 pm Huh... I guess I misunderstood the manual examples. The manual implies the opposite (at least as I read it). So the example that illustrates matching, like: IfMatch=.*Green.*, would also return true if the expression was simply IfMatch=Green? :?
Correct... The question being asked is "does the following exist in the string?"

String=The Green Ball

True:

IfMatch=Green
IfMatch=.*Green.*
IfMatch=The .* Ball

False:

IfMatch=^Green
IfMatch=Green$
IfMatch=Red Ball
IfMatch=Green Tamborine

I tweaked the docs a bit...
nikko
Posts: 44
Joined: December 5th, 2017, 5:58 pm

Re: Understanding Ifmatch

Post by nikko »

Thankz.

1 more question

Code: Select all

;Vars.inc
[Variables]
Signs=XYZ
Meter1=1
Meter2=2
Meter3=3

Code: Select all

;CdnatesMsr.inc
[msSigns]
Measure=String
String=#Signs#
IfMatch=X
IfMatchAction=[!SetVariable Meter1 "1"][!WriteKeyValue Variables Meter1 "1" "#@#Vars.inc"]
IfNotMatchAction=[!SetVariable Meter1 "0"][!WriteKeyValue Variables Meter1 "0" "#@#Vars.inc"]
IfMatch2=Y
IfMatchAction2=[!SetVariable Meter2 "1"][!WriteKeyValue Variables Meter2 "1" "#@#Vars.inc"]
IfNotMatchAction2=[!SetVariable Meter2 "0"][!WriteKeyValue Variables Meter2 "0" "#@#Vars.inc"]
IfMatch3=Z
IfMatchAction3=[!SetVariable Meter3 "1"][!WriteKeyValue Variables Meter3 "1" "#@#Vars.inc"]
IfNotMatchAction3=[!SetVariable Meter3 "0"][!WriteKeyValue Variables Meter3 "0" "#@#Vars.inc"]
DynamicVariables=1

Code: Select all

;CdnatesMtr.ini
[Variables]
@include=Vars.inc
@include2=CdnatesMsr.inc

[mtSign1]
...

[mtSign2]
...

[mtSign3]
...
wai i must refresh this twice to get it working??
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: Understanding Ifmatch

Post by SilverAzide »

nikko wrote: December 18th, 2020, 12:57 pm wai i must refresh this twice to get it working??
Did you use DynamicVariables=1 on all the meters and measures that reference variables #Meter1#, #Meter2#, #Meter3#?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Understanding Ifmatch

Post by balala »

nikko wrote: December 18th, 2020, 12:57 pm wai i must refresh this twice to get it working??
I doubt that in any circumstance a double refresh might help. If the first refresh doesn't help, nor the second one will.
nikko
Posts: 44
Joined: December 5th, 2017, 5:58 pm

Re: Understanding Ifmatch

Post by nikko »

SilverAcide you are right. i missed DynamicVariables and now it works well.
Balala wrong this time. It helped double refresh. One refresh did partial job. Double full job. With DV now it works with 1.
TX
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Understanding Ifmatch

Post by balala »

nikko wrote: December 18th, 2020, 6:17 pm Balala wrong this time. It helped double refresh. One refresh did partial job. Double full job. With DV now it works with 1.
I still doubt, to be honest, because a refresh is a completely destructive procedure. The whole skin is rebuilt when you refresh it, all previous changes are lost, excepting what is written with !WriteKeyValue bangs. But you know.
However I still am curious. Could you please pack the config which contains the skin which has to be double refreshed and post the package here, along with a description on what to do, please?
nikko
Posts: 44
Joined: December 5th, 2017, 5:58 pm

Re: Understanding Ifmatch

Post by nikko »

balala i dont have it anymore.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Understanding Ifmatch

Post by balala »

nikko wrote: December 19th, 2020, 12:18 pm balala i dont have it anymore.
Too bad, because I'd curious. But that's it...
Post Reply