It is currently March 29th, 2024, 11:18 am

if condition

Get help with creating, editing & fixing problems with skins
scub
Posts: 30
Joined: May 16th, 2015, 10:37 pm

if condition

Post by scub »

Basically:
MeasureToday is todays high temp, MeasureTom is tomorrows high temp. i want to check how much warmer or cooler today is going to be compared to tomorrow.. if it's over a couple degrees warmer, but less than 5-6 degrees it's just "warmer", if there is more than 10 degree difference, it's "much warmer".

would like to do the same to check if it's going be cooler instead, or much cooler and maybe get the temp difference, but i can't even get the warmer part working ;)

does [MeterTemp] need a formula or something?

Code: Select all

[MeasureToday]
Measure=Calc
Formula=72

[MeasureTom]
Measure=Calc
Formula=62

[MeterTemp]
Measure=Calc
IfCondition=(MeasureToday > MeasureTom) && ((MeasureToday - MeasureTom) > 1) && ((MeasureToday - MeasureTom) < 6)
IfTrueAction=[!SetOption MeterXYZ Text "It's warmer"]
IfCondition2=(MeasureToday > MeasureTom) && ((MeasureToday - MeasureTom) > 5)
IfTrueAction2=[!SetOption MeterXYZ Text "It's much warmer"]
Last edited by scub on May 21st, 2017, 2:10 pm, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: if condition

Post by jsmorley »

Don't see any [MeasureOne] or [MeasureTwo] that you reference in the IfConditions.
scub
Posts: 30
Joined: May 16th, 2015, 10:37 pm

Re: if condition

Post by scub »

sorry edited/fixed the post, as i was trying to make the code make more sense.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: if condition

Post by jsmorley »

This works for me:

Code: Select all

[MeasureTemp]
Measure=Calc
IfCondition=(MeasureToday - MeasureTom > 0) && (MeasureToday - MeasureTom < 6)
IfTrueAction=[!SetOption MeterXYZ Text "It's warmer"]
IfCondition2=(MeasureToday - MeasureTom > 0) && (MeasureToday - MeasureTom >= 6)
IfTrueAction2=[!SetOption MeterXYZ Text "It's much warmer"]
IfCondition3=(MeasureToday - MeasureTom < 0) && (Abs(MeasureToday - MeasureTom) < 6)
IfTrueAction3=[!SetOption MeterXYZ Text "It's cooler"]
IfCondition4=(MeasureToday - MeasureTom < 0) && (Abs(MeasureToday - MeasureTom) >= 6)
IfTrueAction4=[!SetOption MeterXYZ Text "It's much cooler"]
IfCondition5=MeasureToday - MeasureTom = 0
IfTrueAction5=[!SetOption MeterXYZ Text "It's the same"]
I use the Abs() function https://docs.rainmeter.net/manual/formulas/#Functions just to simplify testing the "difference" even when the difference is negative without having to do a lot of thinking about negative or positive.

This could be at least visually simplified and made a little more clear with:

Code: Select all

[MeasureDiff]
Measure=Calc
Formula=MeasureToday - MeasureTomorrow
IfCondition=(MeasureDiff > 0) && (MeasureDiff < 6)
IfTrueAction=[!SetOption MeterDiff Text "It's warmer"]
IfCondition2=(MeasureDiff > 0) && (MeasureDiff >= 6)
IfTrueAction2=[!SetOption MeterDiff Text "It's much warmer"]
IfCondition3=(MeasureDiff < 0) && (Abs(MeasureDiff) < 6)
IfTrueAction3=[!SetOption MeterDiff Text "It's cooler"]
IfCondition4=(MeasureDiff < 0) && (Abs(MeasureDiff) >= 6)
IfTrueAction4=[!SetOption MeterDiff Text "It's much cooler"]
IfCondition5=MeasureDiff = 0
IfTrueAction5=[!SetOption MeterDiff Text "It's the same"]
scub
Posts: 30
Joined: May 16th, 2015, 10:37 pm

Re: if condition

Post by scub »

thanks! maybe you can help me on another similar query with ifmatch..
is this correct usage? MeasureAlertsFeed in forumla is Stringindex from webparser which may look like:

Code: Select all

<title>Flash Flood Watch issued May 22 at 4:09PM CDT until May 23 at 1:00AM CDT by NWS</title>
i want to check if the entries are Watches/Warnings, and if so, change the font color.. but it's always returns false. how do you search a string for something. in this example, i want to search a StringIndex for "Watch" or "Warning" and change the meter text to yellow.

Code: Select all


[MeasureAlertColor]
Measure=Calc
Formula=MeasureAlertsFeed
IfMatch=.*Watch.*, .*Warning.* : true
IfMatchAction=[!SetOption MeterAlert FontColor 255,0,0,255]
IfNotMatchAction=[!SetOption MeterAlert FontColor 255,255,255,255]
IfMatchMode=1
DynamicVariables=1

[MeterAlert]
Meter=String
MeasureName=MeasureAlertsFeed
FontColor=255,255,255,255
FontSize=10
AntiAlias=1
DynamicVariables=1
Text=%1
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: if condition

Post by mak_kawa »

Edit top of the measure as...

Code: Select all

[MeasureAlertColor]
Measure=String
String=[MeasureAlertsFeed]
IfMatch=Watch, Warning
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: if condition

Post by jsmorley »

mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: if condition

Post by mak_kawa »

My stupid mistake...