It is currently April 8th, 2020, 3:16 pm

[Feature Suggestion] How about a new function: StrCmp ?

Report bugs with the Rainmeter application and suggest features.
User avatar
SilverAzide
Posts: 732
Joined: March 23rd, 2015, 5:26 pm

Re: [Feature Suggestion] How about a new function: StrCmp ?

Post by SilverAzide »

jsmorley wrote:
February 28th, 2020, 3:48 pm
[...], I sorta like the flexibility of "if this string and this value", [...]
What got me looking at this is (sorry, again) weather data. Dark Sky API has terrible icons compared to weather.com. They basically use a few strings like "cloudy" or "rain", and that's it... no distinction of "how cloudy" or "how rainy". The magnitude of these is contained in the data, so to make Dark Sky icons that are as expressive as weather.com, you end up wanting to do a lot of this:

IfCondition=(StrCmp([@CurrentIcon], "rain") == 0 && [@CurrentPrecipitation] > .05 && [@CurrentPrecipitation] < .09)
IfTrueAction=[set the icon number to the "showers" icon]


In other words, mapping their single crappy "rain"" icon to the weather.com's more useful drizzle/showers/rain/heavy rain icons. This is more a job for a Lua script, I know, but it's what got me thinking of strcmp in the first place.
DeviantArt Gadgets More...
User avatar
balala
Rainmeter Sage
Posts: 10094
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Feature Suggestion] How about a new function: StrCmp ?

Post by balala »

SilverAzide wrote:
February 28th, 2020, 4:46 pm
IfCondition=(StrCmp([@CurrentIcon], "rain") == 0 && [@CurrentPrecipitation] > .05 && [@CurrentPrecipitation] < .09)
IfTrueAction=[set the icon number to the "showers" icon]
Note that I read the documentation and found out that the above condition this way in Rainmeter is wrong. It should be
IfCondition=(StrCmp([@CurrentIcon], "rain") == 0 && [@CurrentPrecipitation] > 0.05 && [@CurrentPrecipitation] < 0.09).
The condition doesn't work if you don't add the appropriate zeros.