It is currently November 15th, 2019, 3:44 am

Moments of WebParser update

Tips and Tricks from the Rainmeter Community
User avatar
balala
Rainmeter Sage
Posts: 9052
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Moments of WebParser update

balala » January 2nd, 2015, 7:01 pm

Sometimes when I work with WebParser plugin, I wonder when the WebParser measure access the internet, parsing the needed expression. I know that it can be determined from the used Update and UpdateRate or UpdateDivider, but the theoreticaly determined moments sometimes can differ from the real moments (eg if Rainmeter is busy). I looked for a way to see the time of the update on the skin.
So, here's a little code I made to can see this update moments:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=80,80,80,220
AccurateText=1
DynamicWindowSize=1

[Variables]
Location=
Unit=

[MeasureWeatherRSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=300
Url=http://weather.yahooapis.com/forecastrss?p=#Location#&u=#Unit#
RegExp="(?siU)<b>Current Conditions:</b><br />(.*), (.*)#Unit#<BR />.*<BR /><b>Forecast:</b><BR />.*(.*) - (.*). High: (.*) Low: (.*)<br />.*(.*) - (.*). High: (.*) Low: (.*)<br />.*(.*) - (.*). High: (.*) Low: (.*)<br />.*(.*) - (.*). High: (.*) Low: (.*)<br />.*(.*) - (.*). High: (.*) Low: (.*)<br />"
StringIndex=1
FinishAction=[!UpdateMeasure MeasureCurrentTime][!UpdateMeasure MeasureMain]

[MeasureCurrentTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeatherRSS]
StringIndex=2

[MeasureCurrentTime]
Measure=Time
Format=locale-time
UpdateDivider=-1
OnChangeAction=[!WriteKeyValue Variables "Upd[MeasureMain2]" [MeasureCurrentTime] "#@#UpdateMoments.inc"]
DynamicVariables=1

[MeasureMain]
Measure=Calc
Formula=( MeasureMain + 1 )
UpdateDivider=-1

[MeasureMain2]
Measure=Calc
Formula=( MeasureMain - 1 )

[Meterstatus]
Meter=String
MeasureName=MeasureCurrentTime
MeasureName2=MeasureMain2
X=0
Y=0
Padding=10,5,10,5
FontColor=255,255,255
StringStyle=Bold
stringAlign=LEFT
AntiAlias=1
FontSize=11
FontFace=Segoe UI
Text=Last update: %1#CRLF#Update: %2
For a simple WebParser example the skin determines the current temperature (if you want to try the skin, enter your weather location and the unit - c or f). Not this part of the skin is important, but the skin will show the moment of last update and the number of happend updates. The skin also writes these moments into an UpdateMoments.inc file, as variables.
The code of UpdateMoments.inc is very simple:

Code: Select all

[Variables]
and it must be saved into the resource folder.
When I used this skin, I saw that sometimes the update moments can differ from the theoretical moments with seconds, or even with more.
I don't know if this is useful for anybody, I hope it is, but for me it was interesting to develope a code which can find these moments.
Please leave your comments.