Page 2 of 2

Re: Converting EPOCH time

Posted: December 15th, 2017, 6:57 pm
by jsmorley
While executing this function on each update of the String uses almost no resources, you could "perfect" it from that standpoint by:

Code: Select all

[MeasureTransactions]
Measure=Plugin
Plugin=WebParser
URL=https://vertcoin.easymine.online/json/minertx.php?address=#RxAddress#
RegExp=(?siU):\[\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)"
UpdateRate=120
FinishAction=[!SetOption MeterTXOneTime Text "[&MeasureConvertTime:ConvertTime([&MeasureTXOneTime])]"]

...

[MeterTXOneTime]
Meter=String
MeterStyle=styleRightText
X=230
Y=20r
H=50
Then the result is only asked for and set on each UpdateRate of the parent WebParser measure, and no DynamicVariables is needed on the String meter. Same result, slightly more efficient.

Re: Converting EPOCH time

Posted: December 15th, 2017, 7:06 pm
by balala
jsmorley wrote:Not really a disadvantage as such, but just not the logical way to do it in my view. You want the result "on demand", as requested by the String meter. The inline function approach is clean and simple. When the String meter is updated, it asks for the result and uses it.

If you use Update(), you will get at least one execution that can't possibly return a valid result, as when the Lua Script measure is executed the first time on load / refresh, there can't be any value for the WebParser measure. So even with UpdateDivicer=-1 you will get one invalid / empty response. You can set UpdateDivider=-1 and Disabled=1 on the Lua measure, and have a FinishAction on the WebParser parent enable and update it, but seems like a lot of effort.

There are lots of ways you can get this result, but I feel like what I did is the simplest and uses the least code.
Oh, I see, thanks for the details.

Re: Converting EPOCH time

Posted: December 18th, 2017, 11:47 am
by Swiftzn
Thank you both

Re: Converting EPOCH time

Posted: December 18th, 2017, 9:46 pm
by Swiftzn
jsmorley wrote:While executing this function on each update of the String uses almost no resources, you could "perfect" it from that standpoint by:

Code: Select all

[MeasureTransactions]
Measure=Plugin
Plugin=WebParser
URL=https://vertcoin.easymine.online/json/minertx.php?address=#RxAddress#
RegExp=(?siU):\[\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)".*\{"ts":(.*),"type".*","amount":"(.*)",.*,"balance":"(.*)"
UpdateRate=120
FinishAction=[!SetOption MeterTXOneTime Text "[&MeasureConvertTime:ConvertTime([&MeasureTXOneTime])]"]

...

[MeterTXOneTime]
Meter=String
MeterStyle=styleRightText
X=230
Y=20r
H=50
Then the result is only asked for and set on each UpdateRate of the parent WebParser measure, and no DynamicVariables is needed on the String meter. Same result, slightly more efficient.
Only problem with this is i have 4 other meters that will be calling the convert, so your previous answer would probably be the best bet

Re: Converting EPOCH time

Posted: December 18th, 2017, 9:53 pm
by Swiftzn
I keep getting this every time i use the inline option

Re: Converting EPOCH time

Posted: December 19th, 2017, 12:35 am
by jsmorley
Swiftzn wrote:I keep getting this every time i use the inline option
Make sure you have DynamicVariables=1 on the meters.

Re: Converting EPOCH time

Posted: December 19th, 2017, 9:45 am
by Swiftzn
So this is what my meter looks like

Code: Select all

[MeterTXOneTime]
Meter=String
Text=[&MeasureConvertTime:ConvertTime([&MeasureTXOneTime])]
MeterStyle=styleLeftText
X=15
Y=25r
W=125
DynamicVariables=1
My LUA Measure

Code: Select all

[MeasureConvertTime]
Measure=Script
ScriptFile=ConvertTime.lua
My Lua Script

Code: Select all

function ConvertTime(n)

   return os.date('%B %d %Y %H:%M:%S', n)

end
Still results in not evaluating the inline LUA call.

Re: Converting EPOCH time

Posted: December 19th, 2017, 12:44 pm
by jsmorley
You using Rainmeter 4.1?

Re: Converting EPOCH time

Posted: December 19th, 2017, 1:57 pm
by Swiftzn
wow my bad.

Didn't realize Inline lua was only release in november.. was running rainmeter 4.0 all fixed thanks

Re: Converting EPOCH time

Posted: December 19th, 2017, 2:05 pm
by jsmorley
Swiftzn wrote:wow my bad.

Didn't realize Inline lua was only release in november.. was running rainmeter 4.0 all fixed thanks
Great. I do encourage you to stay current with at least the latest "release" version of Rainmeter, and to be honest I strongly encourage staying current with the latest beta version. Almost everything I do in helping here on the forums will assume that at a minimum you have the latest release, and while I will try to warn, I will use features from the latest beta if I think they help.

Inline Lua is a big deal...