It is currently March 29th, 2020, 12:36 am

Strategy Request: indicate values are LOWER or HIGHER

Help with creating, editing & fixing problems with skins
ms310
Posts: 167
Joined: April 1st, 2015, 7:16 am

Strategy Request: indicate values are LOWER or HIGHER

Post by ms310 »

Hi

I am reading values from a website that change on an hourly basis. I would like my skin to indicate, with each read, if the current values are lower, higher or the same as the previously read value. I am looking for good logic for this (maybe a best practice). My thinking is this:

1. Prior to the WebParser ready store the current value into a variable, overwriting whatever that value is currently
2. Read the new value via WebParser
3. Do the math between the two values and display up, down, same icon, text, or whatever

Does this seem reasonable? Are there some pitfalls with this logic?

Thanks!
mak_kawa
Posts: 543
Joined: December 30th, 2015, 9:47 am

Re: Strategy Request: indicate values are LOWER or HIGHER

Post by mak_kawa »

Hi ms310

I think your strategy is OK. But one thing, when the skin is loaded (refreshed), all variables are empty (or as decsribed in the [Variables] section), so at the first data-get cycle, you can't evaluate "the difference between previous and current data". This could be the problem if the update cycle of the measure is long. And also you can't know the difference from, for example, the "last night/yesterday" value.

My workaround for this is to store variable value to the include file such as Variables.inc by !WriteKeyValue bang at every data update (see the footnote below), so that you can get previous data when the skin is loaded (refreshed) and know the data difference since last unloading.

*) If you don't want to store value when the value is unchanged, OnchangeAction option in the measure can be used.

As always, maybe I am misunderstanding your point. If so, sorry.
User avatar
balala
Rainmeter Sage
Posts: 10009
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Strategy Request: indicate values are LOWER or HIGHER

Post by balala »

Besides mak_kawa's explanation, I'd add an example code for you, to show you how did I achieved something similar. Not knowing your source, I used a Calc measure, but probably similarly could be done even for WebParser measures. The Calc measure is updated regularly (precisely here on each second update cycle, but this can be changes easily) and on each update the skin shows if the new value has increased, decreased or didn't change.
Not sure if you need a sample code or you already have a workaround, but here is my code, if you are interested:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Change=0

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=0
HighBound=100
UpdateRandom=1
IfCondition=(#CURRENTSECTION#>#Change#)
IfTrueAction=[!SetVariable Direction "[\x2197]"]
IfCondition2=(#CURRENTSECTION#<#Change#)
IfTrueAction2=[!SetVariable Direction "[\x2198]"]
IfCondition3=(#CURRENTSECTION#=#Change#)
IfTrueAction3=[!SetVariable Direction "-"]
OnChangeAction=[!Delay "1000"][!SetVariable Change "[MeasureRandom]"][!UpdateMeter "MeterShow"][!Redraw]
DynamicVariables=1
UpdateDivider=2

[MeterShow]
Meter=STRING
MeasureName=MeasureRandom
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1 / #Direction#
DynamicVariables=1
Please let me know if you have any related question.