Page 1 of 1

Formulas in WebParser?

Posted: February 19th, 2019, 2:24 pm
by JayOtt
Hi all!

I'm fairly new to Rainmeter, so this is probably a super simple one...

Is it possible to use a formula in the data that WebParser fetches?

I have this so far - The URL spits out a string of numbers - specifically times in seconds - deliminated by commas.
The meter takes the second of these numbers and displays the number of seconds for that thing.

Code: Select all

[MeasureState]
Measure=WebParser
URL=http://URLThatGivesYouCommaDelinatedNumbers.com
RegExp=(?siU),(.*),.*(.*),.*(.*),.*(.*),.*(.*),.*(.*),.*(..)
UpdateRate=1

[MeasureCurrTime]
Measure=WebParser
URL=[MeasureState]
StringIndex=2

[MeterCurrTime]
MeterStyle=Text
MeasureName=MeasureCurrTime
Meter=String
X=(#WIDTH#*0.2)
Y=(#HEIGHT#/2-(#FONTSIZE#*0.8))
Prefix="Current: "
Postfix=""
My question is; how would I divide that number I get by 60 to get the time in minutes?

Re: Formulas in WebParser?

Posted: February 19th, 2019, 2:37 pm
by jsmorley
JayOtt wrote: February 19th, 2019, 2:24 pm Hi all!

I'm fairly new to Rainmeter, so this is probably a super simple one...

Is it possible to use a formula in the data that WebParser fetches?

I have this so far - The URL spits out a string of numbers - specifically times in seconds - deliminated by commas.
The meter takes the second of these numbers and displays the number of seconds for that thing.

Code: Select all

[MeasureState]
Measure=WebParser
URL=http://URLThatGivesYouCommaDelinatedNumbers.com
RegExp=(?siU),(.*),.*(.*),.*(.*),.*(.*),.*(.*),.*(.*),.*(..)
UpdateRate=1

[MeasureCurrTime]
Measure=WebParser
URL=[MeasureState]
StringIndex=2

[MeterCurrTime]
MeterStyle=Text
MeasureName=MeasureCurrTime
Meter=String
X=(#WIDTH#*0.2)
Y=(#HEIGHT#/2-(#FONTSIZE#*0.8))
Prefix="Current: "
Postfix=""
My question is; how would I divide that number I get by 60 to get the time in minutes?

You are almost certainly going to want to use an Uptime measure for that. You don't want to just divide by 60 and display something like 3.25 minutes, that .25 is meaningless in the context of time. "3 minutes and 25 percent of a minute"? Ick... You want the number of minutes and the remainder of seconds.

https://docs.rainmeter.net/manual/measures/uptime/
https://docs.rainmeter.net/manual/measures/uptime/#SecondsValue

Code: Select all

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

[MeasureSeconds]
Measure=String
String=137

[MeasureMinutesAndSeconds]
Measure=Uptime
SecondsValue=[MeasureSeconds]
DynamicVariables=1
Format=%2!i! minutes and %1!i! seconds

[MeterMinutesAndSeconds]
Meter=String
MeasureName=MeasureMinutesAndSeconds
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

1.jpg

Re: Formulas in WebParser?

Posted: February 19th, 2019, 2:46 pm
by eclectic-tech
jsmorley wrote:"You don't want to display 3.25 minutes, that is meaningless in the context of time."
I beg to differ: Decimal Time ;-)

Two years since that post, and it hasn't caught on... hmm?!

Re: Formulas in WebParser?

Posted: February 19th, 2019, 2:48 pm
by jsmorley
eclectic-tech wrote: February 19th, 2019, 2:46 pm I beg to differ: Decimal Time ;-)

Two years since that post, and it hasn't caught on... hmm?!
So when someone asks you the time, you say "it's three point seventy-eight o'clock"?

You are weirder than I thought... ;-)

Re: Formulas in WebParser?

Posted: February 19th, 2019, 2:56 pm
by eclectic-tech
jsmorley wrote: February 19th, 2019, 2:48 pm So when someone asks you the time, you say "it's three point two-five o'clock"?
"three and a quarter seconds" or "three and a quarter minutes" ... I don't need to say o'clock
since all decimal time is in percentages of the minute, hour, or day... :D

This concept will never catch on... it was an experiment in conversion, but I don't expect anyone to actually adopt it! :thumbdown: :uhuh:

Re: Formulas in WebParser?

Posted: February 19th, 2019, 2:58 pm
by jsmorley
eclectic-tech wrote: February 19th, 2019, 2:56 pm "three and a quarter seconds" or "three and a quarter minutes" ... I don't need to say o'clock
since all decimal time is in percentages of the minute, hour, or day... :D
Sorry, that's fine with the shorthand for quarter or half, as long as you say "after" or "until", but nobody on this planet has taken "metric" that far in their daily lives, and says something like "it's three point seventy-eight o'clock".

Re: Formulas in WebParser?

Posted: February 19th, 2019, 3:02 pm
by JayOtt
Ah ha! Uptime works great!

I ditched the seconds from the string because I'm not interested in that much detail... but that's perfect. Thanks!

Re: Formulas in WebParser?

Posted: February 19th, 2019, 3:02 pm
by jsmorley
Anyway, the original poster is welcome to just use a Calc measure and divide the number of seconds by 60 and end up with 3.78 or whatever, I just suggest that unless you are doing some kind of "math" with the result, where you want to display a Bar meter or something, that result isn't particularly useful.

Re: Formulas in WebParser?

Posted: February 19th, 2019, 3:06 pm
by jsmorley
JayOtt wrote: February 19th, 2019, 3:02 pm Ah ha! Uptime works great!

I ditched the seconds from the string because I'm not interested in that much detail... but that's perfect. Thanks!
Well, in that case, while it isn't any better or worse, you can also use a Calc measure:

Code: Select all

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

[MeasureSeconds]
Measure=String
String=137

[MeasureTruncatedMinutes]
Measure=Calc
Formula=Trunc(MeasureSeconds/60)

[MeterMinutes]
Meter=String
MeasureName=MeasureTruncatedMinutes
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
You could also use Floor(), Ceil() or Round() in the formula if you want to round down, round up, or round naturally. Using Uptime with just the seconds in the Format option is effectively the same as Trunc() or Floor() in a Calc measure.