It is currently May 9th, 2024, 10:10 pm

Weather Problem...

Get help with creating, editing & fixing problems with skins
dr_infernoo
Posts: 17
Joined: August 29th, 2012, 5:41 am

Weather Problem...

Post by dr_infernoo »

I'm having an issue with a weather skin I'm trying to make. I'm trying to make it display a short code for ranges of temperature, like HOT for 80+, WRM for 80-70, CUL for 70-60, and CLD for 60-. I think this code should work, but it won't ever show me WRM or CUL. I am just using different weather codes in my #weathercode# variable to get different ranges of temperatures, and when I use one below 70°, it shows CLD, and above 70°, it shows HOT.

Code: Select all

[MeasureWeatherRSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1000
Url=http://xml.weather.com/weather/local/#weathercode#?cc=*&dayf=6
RegExp="(?siU)<weather ver="(.*)">(.*)<tmp>(.*)</tmp>(.*)<t>(.*)</t>(.*)<icon>(.*)</icon>(.*)<day d="1" t="(.*)" dt="(.*)">(.*)<hi>(.*)</hi>(.*)<low>(.*)</low>(.*)<icon>(.*)</icon>(.*)<t>(.*)</t>(.*)<day d="2" t="(.*)" dt="(.*)">(.*)<hi>(.*)</hi>(.*)<low>(.*)</low>(.*)<icon>(.*)</icon>(.*)<t>(.*)</t>(.*)<day d="3" t="(.*)" dt="(.*)">(.*)<hi>(.*)</hi>(.*)<low>(.*)</low>(.*)<icon>(.*)</icon>(.*)<t>(.*)</t>(.*)"
StringIndex=1

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeatherRSS]
StringIndex=3

[MeasureWeatherHot]
Measure=Calc
Formula=MeasureWeatherTemp
IfAboveValue=80
IfAboveAction=[!HideMeter MeterWeatherCold][!ShowMeter MeterWeatherHot][!HideMeter MeterWeatherCool][!HideMeter MeterWeatherWarm]

[MeasureWeatherWarm]
Measure=Calc
Formula=MeasureWeatherTemp
IfBelowValue=80
IfBelowAction=[!HideMeter MeterWeatherCold][!HideMeter MeterWeatherHot][!HideMeter MeterWeatherCool][!ShowMeter MeterWeatherWarm]

[MeasureWeatherCool]
Measure=Calc
Formula=MeasureWeatherTemp
IfBelowValue=70
IfBelowAction=[!HideMeter MeterWeatherCold][!HideMeter MeterWeatherHot][!ShowMeter MeterWeatherCool][!HideMeter MeterWeatherWarm]

[MeasureWeatherCold]
Measure=Calc
Formula=MeasureWeatherTemp
IfBelowValue=60
IfBelowAction=[!ShowMeter MeterWeatherCold][!HideMeter MeterWeatherHot][!HideMeter MeterWeatherCool][!HideMeter MeterWeatherWarm]

[MeterWeatherCool]
Meter=String
X=57
Y=0
FontColor=#color#
FontFace=Arial Black
FontSize=7
AntiAlias=1
Text=CUL

[MeterWeatherWarm]
Meter=String
X=57
Y=0
FontColor=#color#
FontFace=Arial Black
FontSize=7
AntiAlias=1
Text=WRM

[MeterWeatherCold]
Meter=String
X=57
Y=0
FontColor=#color#
FontFace=Arial Black
FontSize=7
AntiAlias=1
Text=CLD

[MeterWeatherHot]
Meter=String
X=57
Y=0
FontColor=#color#
FontFace=Arial Black
FontSize=7
AntiAlias=1
Text=HOT
Any ideas?
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Weather Problem...

Post by MerlinTheRed »

I think your problem is most likely due to those IfActions only firing once, when the condition becomes true for the first time. You need something that handles all the cases at the same time. Something like this might work:

Code: Select all

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeatherRSS]
StringIndex=3

[MeasureTempCode]
Measure=Calc
Formula=MeasureWeatherTemp < 60 ? 1 : (MeasureWeatherTemp < 70 ? 2 : (MeasureWeatherTemp < 80 ? 3 : 4))
Substitute="1":"CLD", "2":"CUL", "3":"WRM", "4":"HOT"

[MeterWeatherTXT]
Meter=String
MeasureName=MeasureTempCode
X=57
Y=0
FontColor=#color#
FontFace=Arial Black
FontSize=7
AntiAlias=1
This complicated formula transforms those temperature intervals into integer numbers. In case you don't know that construct, it essentially means:

<condition> ? <return_this_if_true> : <else_return_this>

Very handy in a lot of cases.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weather Problem...

Post by jsmorley »

There is a little more explanation and a couple of examples of using "conditional formulas" here:

http://rainmeter.net/cms/Measures-Calc_beta
dr_infernoo
Posts: 17
Joined: August 29th, 2012, 5:41 am

Re: Weather Problem...

Post by dr_infernoo »

Gotcha. I totally should've thought of that, except I didn't know what that Substitute function did :P