It is currently April 19th, 2024, 4:27 am

Change text based on two conditions

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 865
Joined: January 4th, 2018, 9:52 pm

Change text based on two conditions

Post by xenium »

Hi,
How can I do this:

Code: Select all

[MeasureX]
Measure=Calc
IfCondition=MeasureB = 0
IfTrueAction=[!SetOption MeterX Text "Text1"]
IfCondition2=MeasureA < 14 AND (MeasureB >= 1) && (MeasureB <= 49)
IfTrueAction2=[!SetOption MeterX Text "Text2"]
IfCondition3=MeasureA < 14 AND MeasureB = 50
IfTrueAction3=[!SetOption MeterX Text "Text3"]
IfCondition4=MeasureA < 14 AND (MeasureB >= 51) && (MeasureB <= 99)
IfTrueAction4=[!SetOption MeterX Text "Text4"]
IfCondition5=MeasureB = 100
IfTrueAction5=[!SetOption MeterX Text "Text5"]
IfCondition6=MeasureA > 14 AND (MeasureB >= 51) && (MeasureB <= 99)
IfTrueAction6=[!SetOption MeterX Text "Text6"]
IfCondition7=MeasureA > 14 AND MeasureB = 50
IfTrueAction7=[!SetOption MeterX Text "Text7"]
IfCondition8=MeasureA > 14 AND (MeasureB >= 1) && (MeasureB <= 49)
IfTrueAction8=[!SetOption MeterX Text "Text8"]
Thank you
Last edited by balala on October 17th, 2018, 7:21 am, edited 1 time in total.
Reason: Please use code tags when posting code.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Change text based on two conditions

Post by kyriakos876 »

xenium wrote: October 16th, 2018, 11:40 am Hi,
How can I do this:

[MeasureX]
Measure=Calc
IfCondition=MeasureB = 0
IfTrueAction=[!SetOption MeterX Text "Text1"]
IfCondition2=MeasureA < 14 AND (MeasureB >= 1) && (MeasureB <= 49)
IfTrueAction2=[!SetOption MeterX Text "Text2"]
IfCondition3=MeasureA < 14 AND MeasureB = 50
IfTrueAction3=[!SetOption MeterX Text "Text3"]
IfCondition4=MeasureA < 14 AND (MeasureB >= 51) && (MeasureB <= 99)
IfTrueAction4=[!SetOption MeterX Text "Text4"]
IfCondition5=MeasureB = 100
IfTrueAction5=[!SetOption MeterX Text "Text5"]
IfCondition6=MeasureA > 14 AND (MeasureB >= 51) && (MeasureB <= 99)
IfTrueAction6=[!SetOption MeterX Text "Text6"]
IfCondition7=MeasureA > 14 AND MeasureB = 50
IfTrueAction7=[!SetOption MeterX Text "Text7"]
IfCondition8=MeasureA > 14 AND (MeasureB >= 1) && (MeasureB <= 49)
IfTrueAction8=[!SetOption MeterX Text "Text8"]

Thank you
First of all there's no such thing as AND you need to use &&
And keep in mind you need to use parenthesis for logical operations.

https://docs.rainmeter.net/manual/measures/general-options/ifconditions/

Now your code would be:

Code: Select all

[MeasureX]
Measure=Calc
IfCondition=[MeasureB] = 0
IfTrueAction=[!SetOption MeterX Text "Text1"]
IfCondition2=(([MeasureA] < 14) && (([MeasureB] >= 1) && ([MeasureB] <= 49)))
IfTrueAction2=[!SetOption MeterX Text "Text2"]
IfCondition3=(([MeasureA] < 14) && ([MeasureB] = 50))
IfTrueAction3=[!SetOption MeterX Text "Text3"]
IfCondition4=(([MeasureA] < 14) && ([MeasureB] >= 51) && ([MeasureB] <= 99))
IfTrueAction4=[!SetOption MeterX Text "Text4"]
IfCondition5=[MeasureB] = 100
IfTrueAction5=[!SetOption MeterX Text "Text5"]
IfCondition6=(([MeasureA] > 14) && ([MeasureB] >= 51) && ([MeasureB] <= 99))
IfTrueAction6=[!SetOption MeterX Text "Text6"]
IfCondition7=(([MeasureA] > 14) && ([MeasureB] = 50))
IfTrueAction7=[!SetOption MeterX Text "Text7"]
IfCondition8=(([MeasureA] > 14) && ([MeasureB] >= 1) && ([MeasureB] <= 49))
IfTrueAction8=[!SetOption MeterX Text "Text8"]
Excuse me if I forgot any parenthesis....
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Change text based on two conditions

Post by jsmorley »

There is no literal AND logical operator in Rainmeter, it is defined with the && logical operator. Keep in mind that the two components of a logical && must be enclosed in (parentheses).

So it will always be:

(if this) && (if that)
(if this) && ((if that) && (if the other))

Code: Select all

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

[MeasureA]
Measure=Calc
Formula=3

[MeasureB]
Measure=Calc
Formula=70

[MeasureX]
Measure=Calc
IfCondition=MeasureB = 0
IfTrueAction=[!SetOption MeterX Text "Text1"]
IfCondition2=(MeasureA < 14) && ((MeasureB >= 1) && (MeasureB <= 49))
IfTrueAction2=[!SetOption MeterX Text "Text2"]
IfCondition3=(MeasureA < 14) && (MeasureB = 50)
IfTrueAction3=[!SetOption MeterX Text "Text3"]
IfCondition4=(MeasureA < 14) && ((MeasureB >= 51) && (MeasureB <= 99))
IfTrueAction4=[!SetOption MeterX Text "Text4"]
IfCondition5=MeasureB = 100
IfTrueAction5=[!SetOption MeterX Text "Text5"]
IfCondition6=(MeasureA > 14) && ((MeasureB >= 51) && (MeasureB <= 99))
IfTrueAction6=[!SetOption MeterX Text "Text6"]
IfCondition7=(MeasureA > 14) && (MeasureB = 50)
IfTrueAction7=[!SetOption MeterX Text "Text7"]
IfCondition8=(MeasureA > 14) && ((MeasureB >= 1) && (MeasureB <= 49))
IfTrueAction8=[!SetOption MeterX Text "Text8"]

[MeterX]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
The same is true with a logical OR, which is ||.

Edit: kyriakos876 beat me to it! :-)

kyriakos876, Two notes.

While they do no harm, the outer (parentheses) are not required on the Formula option of a Calc measure, or on an IfCondition. Those are by their nature assumed to be numeric formulas.

You do not need to use a measure value as a [SectionVariable] in either the Formula option of a Calc measure, or on an IfCondition. Since these are again assumed to be numeric, a text name like "MeasureA" can only refer to the measure [MeasureA]. If you do use a [SectionVariable] in the formula or comparison, you must use DynamicVariables=1.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Change text based on two conditions

Post by kyriakos876 »

jsmorley wrote: October 16th, 2018, 12:07 pm While they do no harm, the outer (parentheses) are not required on the Formula option of a Calc measure, or on an IfCondition. Those are by their nature assumed to be numeric formulas.

You do not need to use a measure value as a [SectionVariable] in either the Formula option of a Calc measure, or on an IfCondition. Since these are again assumed to be numeric, a text name like "MeasureA" can only refer to the measure [MeasureA]. If you do use a [SectionVariable] in the formula or comparison, you must use DynamicVariables=1.
The-more-you-know.png
You do not have the required permissions to view the files attached to this post.
User avatar
xenium
Posts: 865
Joined: January 4th, 2018, 9:52 pm

Re: Change text based on two conditions

Post by xenium »

Thanks for the help ! :welcome: