It is currently April 20th, 2024, 9:17 am

Beginner Question - Create output strings from WebParser Child Measures

Get help with creating, editing & fixing problems with skins
User avatar
frossm
Posts: 6
Joined: September 26th, 2017, 1:06 pm

Beginner Question - Create output strings from WebParser Child Measures

Post by frossm »

Hello everyone,

I've been using Rainmeter for some time, but just started to work on my first skin. I've used Webparser to get the data I needed from a webpage and have child measures with the specific data strings broken out. That's worked well.

However, in the meter, I'd like to concatenate those child data items into an output string. But it seems like a meter is tied to a single measure. I'd like to take these various items, and format them into a string I can display in the measure.

I can include the code if it will help.

Thanks for you help everyone. This is a lot of fun.

Michael
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by balala »

A string meter (and not just) can use the data returned by more measures. You just have to add the name of the first measure to a MeasureName option, the name of the second measure to a MeasureName2 option and so on. Then you can refere to any of the returned string with %1, %2 (and so on). Eg the Text=%1#CRLF#%2 option will show the string returned by the measure added to the MeasureName into first line and the string returned by the measure provided into the MeasureName2 option into the second line.
Furtherly you can format the strings using Inline options.
For specific help, we indeed would need the code. Post it, along with a description of what would you like to achieve.
User avatar
frossm
Posts: 6
Joined: September 26th, 2017, 1:06 pm

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by frossm »

Thank you Balala.

Maybe this will make is clearer. Here is a simple test skin. I'd like to use the measures as section variables. This is obviously a nonsense use case, but it shows what I'm trying to do.

How can I take the meterTest1 meter and concat the section variables together with strings to create an output?

I really appreciate the guidance.

Michael

Code: Select all

[Rainmeter]
Update=10000
AccurateText=1
BackgroundMode=2

[Metadata]
Name=Test
Author=Frosty
Information=test
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

; ------------------------------------------------------
; Measures
; ------------------------------------------------------
[MeasureParent]
Measure=Plugin
Plugin=WebParser
URL=https://www.rainmeter.net
RegExp=(?siU)<h4>(.*)\s-\s(.*)</h4>
Debug=2

[MeasureVersion]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasureBuild]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=2


;-----------------------------------------------------
; Meters
;-----------------------------------------------------

[meterTitle]
Meter=String
X=100
Y=12
W=190
H=25
FontColor=0,0,0
FontSize=20
Text=Title

[meterTest1]
Meter=String
X=10
Y=40
W=190
FontColor=0,0,0
FontSize=20
Text=[MeasureBuild] + "<->" + [MeasureVersion]
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by ikarus1969 »

As Balala already said, use "MeasureName" and "MeasureName2" on "meterTest1" and use "%1" and "%2" in the "Text"-Property of the meter:
You can read the docu regarding this:
https://docs.rainmeter.net/manual-beta/meters/general-options/#MeasureName
https://docs.rainmeter.net/manual-beta/meters/string/#Text

edit: ...and don't forget to use "UpdateRate" on your WebParser-Measure (docu: https://docs.rainmeter.net/manual-beta/plugins/webparser/#UpdateRate) to not access the site too often!
Screenshot Rainmeter.jpg

Code: Select all

[meterTest1]
Meter=String
X=10
Y=40
W=190
FontColor=0,0,0
FontSize=20
MeasureName=MeasureBuild
MeasureName2=MeasureVersion
Text=%1 + "<->" + %2
You do not have the required permissions to view the files attached to this post.
User avatar
frossm
Posts: 6
Joined: September 26th, 2017, 1:06 pm

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by frossm »

Thank you very much ikarus1969. For some reason I was thinking that you could only bind a Meter to one Measure. Not sure why I thought that.

Ok, I can continue down the path until the next issue :D

Much appreciated guys.

Michael
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by balala »

frossm wrote:Maybe this will make is clearer. Here is a simple test skin. I'd like to use the measures as section variables. This is obviously a nonsense use case, but it shows what I'm trying to do.

How can I take the meterTest1 meter and concat the section variables together with strings to create an output?
No, it's not a nonsense at all. Beside ikarus1969's reply, you have to know that although not usual and desirable to create a String meter with section variables, your code works perfectly. The only missing option is a DynamicVariables=1, which should be added to the [meterTest1] meter.
On the other hand, indeed is a better idea to use MeasureName options on the String meter, as ikarus1969 said:

Code: Select all

[meterTest1]
Meter=String
MeasureName=MeasureBuild
MeasureName2=MeasureVersion
X=10
Y=40
W=190
FontColor=0,0,0
FontSize=20
Text=%1 + "<->" + %2
In this case the DynamicVariables=1 option is not needed.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by balala »

ikarus1969 wrote:edit: ...and don't forget to use "UpdateRate" on your WebParser-Measure (docu: https://docs.rainmeter.net/manual-beta/plugins/webparser/#UpdateRate) to not access the site too often!
I don't think it is needed. The default value of the UpdateRate option is 600, meaning 10 minutes, which usually is enough. Because frossm didn't add a such option to the [MeasureParent] measure, the default value is used.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by ikarus1969 »

balala wrote:I don't think it is needed. The default value of the UpdateRate option is 600, meaning 10 minutes, which usually is enough. Because frossm didn't add a such option to the [MeasureParent] measure, the default value is used.
I think it is needed. First, i think his skin is just a test-skin as he wrote, so that hint for his "production"-skin is not so bad. Second, he used a set Update=10000 in the rainmeter-section which would result in a much longer interval, which, probably, is too long for his needs. It was just a reminder for him... And third, for me, it's always a goo habit to code some (not all) values explicitly for defaults may change and so, again for me, it's better to maintain.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by balala »

ikarus1969 wrote:Second, he used a set Update=10000 in the rainmeter-section
:o Indeed, I didn't realize this detail. You're right about this. :o
User avatar
frossm
Posts: 6
Joined: September 26th, 2017, 1:06 pm

Re: Beginner Question - Create output strings from WebParser Child Measures

Post by frossm »

Thanks all. I appreciate the reminder. The code was just a thrown together test.

I've since set the [Rainmeter] Update back to 1000 and included an UpdateRate in my WebParser measure to 300. This would be 300 iterations of the 1000 (or 5 minutes assuming I understand this correctly.)

The docs are well written, but it takes a bit of getting used to as I just started on the skin yesterday.

I'm happy to see such a vibrant community and I look forward to participating as I gain in knowledge.

Kind regards,

Michael