It is currently April 20th, 2024, 7:48 am

IfMatch Question

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

Re: IfMatch Question

Post by balala »

Ok jsmorley, let's not go further with the assumptions and wait for xenium's explanations, to see what he wants.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfMatch Question

Post by jsmorley »

balala wrote: December 10th, 2018, 4:12 pm Ok jsmorley, let's not go further with the assumptions and wait for xenium's explanations, to see what he wants.


See? This is the entire point of my original answer... ;-)
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatch Question

Post by balala »

jsmorley wrote: December 10th, 2018, 4:19 pm See? This is the entire point of my original answer... ;-)
:thumbup: :great:
User avatar
xenium
Posts: 865
Joined: January 4th, 2018, 9:52 pm

Re: IfMatch Question

Post by xenium »

Sorry,
I think the example of RegExp was not suitable to express what I want to do and created confusion ... sorry again :oops:

I try to explain otherwise:
If RegExp returns, Red AND Blue, disable [MeasureB] (use IfMatch = Red. * Blue)
OR
If RegExp does not return anything (HTML is missing), disable [MeasureB]
(Here I do not know what to use ...)

Finally, it should look like this:

Code: Select all

IfMatch = Red. * Blue | ???
IfMatchAction=[!DisableMeasure "MeasureB"]
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfMatch Question

Post by jsmorley »

xenium wrote: December 10th, 2018, 5:01 pm Sorry,
I think the example of RegExp was not suitable to express what I want to do and created confusion ... sorry again :oops:

I try to explain otherwise:
If RegExp returns, Red AND Blue, disable [MeasureB] (use IfMatch = Red. * Blue)
OR
If RegExp does not return anything (HTML is missing), disable [MeasureB]
(Here I do not know what to use ...)

Finally, it should look like this:

Code: Select all

IfMatch = Red. * Blue | ???
IfMatchAction=[!DisableMeasure "MeasureB"]
I need an example of the actual XML you are parsing, and an example of the actual RegExp option you are using.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfMatch Question

Post by balala »

jsmorley wrote: December 10th, 2018, 6:34 pm I need an example of the actual XML you are parsing, and an example of the actual RegExp option you are using.
Agree. But here is an example code I wrote in the meantime:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureFile]
Measure=WebParser
URL=#URL#
RegExp=(?siU)(?(?=<item>)<item>(?(?=.*<Name1>).*<Name1>(.*)</Name1>)(?(?=.*<Name2>).*<Name2>(.*)</Name2>))

[Measure1]
Measure=WebParser
Url=[MeasureFile]
IfMatch=^$
IfMatchAction=[!SetVariable Match1 "0"]
IfMatch2=Red
IfMatchAction2=[!SetVariable Match1 "1"]
IfMatch3=^$|Red
IfNotMatchAction3=[!SetVariable Match1 "-10"]
StringIndex=1

[Measure2]
Measure=WebParser
Url=[MeasureFile]
IfMatch=^$
IfMatchAction=[!SetVariable Match2 "0"]
IfMatch2=Blue
IfMatchAction2=[!SetVariable Match2 "1"]
IfMatch3=^$|Blue
IfNotMatchAction3=[!SetVariable Match2 "-10"]
StringIndex=2

[MeasureNames]
Measure=Calc
Formula=( #Match1# + #Match2# )
IfCondition=((#CURRENTSECTION#=0)||(#CURRENTSECTION#=2))
IfTrueAction=[!DisableMeasure "MeasureB"][!SetOption MeterStatus Text "Disabled"]
IfFalseAction=[!EnableMeasure "MeasureB"][!SetOption MeterStatus Text "Enabled"]
DynamicVariables=1

[MeterStatus]
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
This code enables the measure if the strings in the mentioned file are either both empty, or are Red and Blue accordingly. If any of those strings match the appropriate "color", while the other doesn't or is empty, the measure is enabled.
Does this code meats your needs xenium?