It is currently April 20th, 2024, 9:03 am

IfCondition Measure in a range of values

Get help with creating, editing & fixing problems with skins
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

IfCondition Measure in a range of values

Post by krakoukas »

Hi Friends,

I have to use this line a lot of times in a skin :

Code: Select all

IfCondition=(MeasureName = "XXXX") || (MeasureName = "YYYY") || (MeasureName = "ZZZZ")
Is there a way to write a Condition like this :

Code: Select all

Tab =(XXXX, YYYY, ZZZZ)

IfCondition = MeasureName in Tab
...
IfCondition = MeasureName in Tab
...
IfCondition = MeasureName in Tab
...
Or maybe with another MeasureCheck ? Best way ?
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfCondition Measure in a range of values

Post by balala »

krakoukas wrote: July 18th, 2019, 10:56 am Or maybe with another MeasureCheck ? Best way ?
IfCondition is completely numeric. You can't use it to check strings. For a such action, you have to use IfMatch instead. Something like this: IfMatch=XXXX | YYYY | ZZZZ. There also are the IfMatchAction (executed when the measure match one of the enumerated strings) and IfNotMatchAction (executed when the measure doesn't match none of the enumerated strings) options.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition Measure in a range of values

Post by jsmorley »

I don't fully understand what you are going for here. We seem to have a mixture of things going on here. Is "Tab" a variable? If so then you would need to get it into a measure first in order to use IfMatch on it.

Code: Select all

[Variables]
Tab=(XXXX, YYYY, ZZZZ)

[MeasureString]
Measure=String
String=#Tab#
DynamicVariables=1
IfMatch=XXXX
IfMatchAction=[!Log "It's XXXX"]
IfMatch2=YYYY
IfMatchAction2=[!Log "It's YYYY"]
IfMatch3=ZZZZ
IfMatchAction3=[!Log "It's ZZZZ"]
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

Re: IfCondition Measure in a range of values

Post by krakoukas »

Thanks for help

Well, this works :

Code: Select all

[Measure]
IfMatch=XXX|YYY|ZZZ
IfMatchAction=[!SetOption do something]
IfNotMatchAction=[!SetOption do other thing]
IfMatchMode=1
But this does not. Why ?

Code: Select all

Substitutes=XXX|YYY|ZZZ
-- Substitutes="XXX|YYY|ZZZ" 
-- does not work anymore

[Measure]
IfMatch=#Substitutes#
IfMatchAction=[!SetOption do something]
IfNotMatchAction=[!SetOption do other thing]
IfMatchMode=1
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition Measure in a range of values

Post by jsmorley »

krakoukas wrote: July 18th, 2019, 12:54 pm Thanks for help

Well, this works :

Code: Select all

[Measure]
IfMatch=XXX|YYY|ZZZ
IfMatchAction=[!SetOption do something]
IfNotMatchAction=[!SetOption do other thing]
IfMatchMode=1
But this does not. Why ?

Code: Select all

Substitutes=XXX|YYY|ZZZ
-- Substitutes="XXX|YYY|ZZZ" 
-- does not work anymore

[Measure]
IfMatch=#Substitutes#
IfMatchAction=[!SetOption do something]
IfNotMatchAction=[!SetOption do other thing]
IfMatchMode=1
Because the value being tested by IfMatch is and must be the value being returned by the measure it is on. You can't manually define the value that is being tested.

You would need something like this:

Code: Select all

Substitutes=XXX|YYY|ZZZ
-- Substitutes="XXX|YYY|ZZZ" 
-- does not work anymore

[Measure]
Measure=String
String=#Substitutes#
DynamicVariables=1
IfMatch=XXX|YYY|ZZZ
IfMatchAction=[!SetOption do something]
IfNotMatchAction=[!SetOption do other thing]
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition Measure in a range of values

Post by jsmorley »

I would caution that care be given to using IfMatchMode=1 on this. Ensure that you really mean, and really need, for it to fire the action EVERY TIME the measure is updated, even if the values being tested remain the same. Make sure you really want to spend the resources that entails.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

Re: IfCondition Measure in a range of values

Post by krakoukas »

Sorry I don't understand. Here is my code :

Code: Select all


Filters=Rainmeter|rainmeter|UTorrent|svchost

[MeasureProcess]
Measure=Plugin
Plugin=UsageMonitor
Alias=CPU
Index=1

DynamicVariables=1
IfMatch=#Filters#
IfMatchAction=[!SetOption MeterProcess_Icone ImageName "#@#Images\\Ping\\Dot.png"]
IfNotMatchAction=[!SetOption MeterProcess_Icone ImageName "#@#Images\\Ping\\Question.png"]
This code does not work. I would like the 1st process icon to be a DOT if rainmeter|UTorrent|svchost and a QUESTION if not.
Possible ?
Last edited by krakoukas on July 18th, 2019, 1:12 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition Measure in a range of values

Post by jsmorley »

Not sure. Seems to work for me...

Code: Select all

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

[Variables]
Filters=Rainmeter|rainmeter|UTorrent|svchost

[MeasureProcess]
Measure=Plugin
Plugin=UsageMonitor
Alias=CPU
Index=1
DynamicVariables=1
IfMatch=#Filters#
IfMatchAction=[!Log "Found"]
IfNotMatchAction=[!Log "Not Found"]
While I'm watching the log I can see the "top" process changing from Rainmeter.exe to Firefox.exe from time to time, and the log entry is the correct one.
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France

Re: IfCondition Measure in a range of values

Post by krakoukas »

jsmorley wrote: July 18th, 2019, 1:12 pm Not sure. Seems to work for me...
Indeed, it does !
Thank you a lot Jsmorley, the #Filters# variables wasn't in the Variables section and wasn't interpreted. Works great & Thank you, as always !
Another stupid question from me, Balala :welcome:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition Measure in a range of values

Post by jsmorley »

Good deal...