It is currently September 8th, 2024, 12:20 am

Can't pass measure value to web parser

Get help with creating, editing & fixing problems with skins
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Can't pass measure value to web parser

Post by Kotofanchik »

I'm trying to pass the found data update time value to the web parser to get values ​​starting from this time.

Code: Select all

[mfactvalidHourcalc]
Measure		=Calc
Formula=mfactvalidHour
IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption WindVal Text "control"][!UpdateMeter "mStartHour"]
DynamicVariables=1

[mStartHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$"
StringIndex	=1
StringIndex2=1
DynamicVariables=1
;UpdateDivider=5
A null value is transmitted and nothing else.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

Kotofanchik wrote: June 24th, 2024, 12:14 pm I'm trying to pass the found data update time value to the web parser to get values ​​starting from this time.

Code: Select all

[mfactvalidHourcalc]
Measure		=Calc
Formula=mfactvalidHour
IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption WindVal Text "control"][!UpdateMeter "mStartHour"]
DynamicVariables=1

[mStartHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$"
StringIndex	=1
StringIndex2=1
DynamicVariables=1
;UpdateDivider=5
A null value is transmitted and nothing else.
Didn't check your attachement, but, assuming the rest of your code is otherwise correct, I think your answer is here:
https://docs.rainmeter.net/manual/measures/webparser/#Dynamic
So, your existing [!UpdateMeter "mStartHour"] (and possibly Url =[mTotal], but only if [mTotal] isn't a WebParser measure, otherwise disregard this part) should be adjusted accordingly.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

It's still not clear how to do it. How to automatically delay the [mStartHour] check each time until [mfactvalidHour] has already analyzed the site? If that's the problem at all.
Changed it as I understood

Code: Select all

[mfactvalidHourcalc]
Measure		=Calc
Formula=mfactvalidHour
IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption WindVal Text "control"][!CommandMeasure mStartHour Update]
DynamicVariables=1
I did this, it didn't help. If I manually enter the mStartHour value, it works, but the value 0 is passed as a variable. although it is equal to 12

for example, this is how it all works.

Code: Select all

[mfactvalidHourcalc]
Measure		=Calc
;Formula=mfactvalidHour
Formula=12
IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption WindVal Text "control"][!CommandMeasure mStartHour Update]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16499
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Can't pass measure value to web parser

Post by balala »

Kotofanchik wrote: June 24th, 2024, 12:14 pm I'm trying to pass the found data update time value to the web parser to get values ​​starting from this time.

Code: Select all

[mfactvalidHourcalc]
Measure		=Calc
Formula=mfactvalidHour
IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption WindVal Text "control"][!UpdateMeter "mStartHour"]
DynamicVariables=1

[mStartHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$"
StringIndex	=1
StringIndex2=1
DynamicVariables=1
;UpdateDivider=5
A null value is transmitted and nothing else.
The option works perfectly, but there are more places where the Text option of the [WindVal] meter is set. You've set this option into the IfTrueAction and IfTrueAction2 options of the [mDir] and [mDirm] measures and finally into the IfTrueAction option of the posted [mfactvalidHourcalc] measure (all these measures are placed into the Measures.inc included file). In such cases it's extremely hard to follow what is going on, which option is applied. I recommend to set any option into one single place / measure. There are more possibilities how can you do this, please come back if you don't know how to do it.
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

I made an option with manually entering the number 12. It works as intended. and replaced VindVal with Control
But it is necessary that the number 12 from the mfactvalidHour measure be transmitted in the same way

I think we need to delay the start of the RegExp check even further in the [mStartHour] measure so that the value from [mfactvalidHour] has a normal value and not a zero value, but I don’t know how to do this.
Yincognito wrote: June 24th, 2024, 1:14 pm [mTotal][/Snippet] isn't a WebParser measure, otherwise disregard this part) should be adjusted accordingly.
Yes, [mTotal] is also a webparser.

I'm confused about what and how and where to hold it.. :)
You do not have the required permissions to view the files attached to this post.
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

That's it, I realized who needed to be updated. :)
It worked.
I don’t understand why it was necessary to update the parent measure [mtotal], but updating it helped.

Code: Select all

[mfactvalidHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)#factvalidHour#"
StringIndex	=1
StringIndex2=1
DynamicVariables=1


[mfactvalidHourcalc]
Measure		=Calc
Formula=mfactvalidHour
;Formula=12
;IfConditionMode=1
IfCondition=(mfactvalidHour > 0)
IfTrueAction=[!SetOption Control Text "control"][!CommandMeasure mTotal Update]
DynamicVariables=1






[mStartHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$"
StringIndex	=1
StringIndex2=1
DynamicVariables=1
;UpdateDivider=5
You do not have the required permissions to view the files attached to this post.
Last edited by Kotofanchik on June 24th, 2024, 3:51 pm, edited 1 time in total.
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

Has anyone ever encountered calculating the day of the week using the full current date from a parsed web resource? I seemed to have found the formula, but I couldn’t figure out how to implement it in the Rainmeter.
User avatar
Yincognito
Rainmeter Sage
Posts: 8030
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

Kotofanchik wrote: June 24th, 2024, 3:38 pm That's it, I realized who needed to be updated. :)
It worked.
I don’t understand why it was necessary to update the parent measure [mtotal], but updating it helped.
That's how WebParser works: when you dynamically change one of its options, you need to retrieve the resource again. Good job in eventually figuring it out in your code. :thumbup:

Just so you know for the future, to avoid the redundancy, you could have always got the forecast from the "fact" hour onwards via some WebParser with RegExp=(?siU).*<fact valid="(.*)".*<forecast valid="\1" tod(.*)$, and then just empty the measure containing the 2nd capture using a !SetOption or a Substitute (or even similarly alter the meters instead) if the measure containing the 1st capture was equivalent to a "zero hour" datetime (this part could have been done in an IfMatch):
Forecast.jpg
Yes, you can use \1, \2 and so on to reference captures even inside the input string, not just in the replacement. By the way, regarding regex, the characters you need to escape to literals by preceding them with a \ are the reserved ones here (and not the quotes, like in your code):
https://docs.rainmeter.net/manual/measures/general-options/ifmatchactions/
Kotofanchik wrote: June 24th, 2024, 3:45 pm Has anyone ever encountered calculating the day of the week using the full current date from a parsed web resource? I seemed to have found the formula, but I couldn’t figure out how to implement it in the Rainmeter.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,255,0,255

[WebParsedDateEquivalent]
Measure=String
String=2015-01-27T15:22:30

[DOW]
Measure=Time
TimeStampFormat=%Y-%m-%dT%H:%M:%S
TimeStamp=[WebParsedDateEquivalent]
Format=%A
DynamicVariables=1

[DOWText]
Meter=String
MeasureName=DOW
Text=DOW: %1
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 149
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

Wow, I'm ready to calculate the formulas. And I read about TimeStamp just a couple of days ago, but didn’t realize that there was such a possibility
User avatar
balala
Rainmeter Sage
Posts: 16499
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Can't pass measure value to web parser

Post by balala »

Kotofanchik wrote: June 24th, 2024, 3:38 pm It worked.
:thumbup:
Kotofanchik wrote: June 24th, 2024, 3:38 pm That's it, I realized who needed to be updated. :)
It worked.
I don’t understand why it was necessary to update the parent measure [mtotal], but updating it helped.
The [mfactvalidHourcalc] measure looks not to be necessary. It's only reason is the use of the IfCondition (and obviously the appropriate IfTrueAction). But these options can be added directly to the [mfactvalidHour] WebParser measure, no need for another measure, just to add the IfCondition to that measure.
Yincognito wrote: June 24th, 2024, 5:27 pm That's how WebParser works: when you dynamically change one of its options, you need to retrieve the resource again.
Not sure where any option of the parent WebParser measure ([mTotal] in this case) has been altered (at least not from the posted piece of code). Am I missing something?