It is currently April 27th, 2024, 12:00 am

Placing value of a measure inside Regexp?

Get help with creating, editing & fixing problems with skins
Thomasne
Posts: 5
Joined: August 24th, 2014, 7:57 pm

Placing value of a measure inside Regexp?

Post by Thomasne »

Hi!

I'm making a simple skin that shows a text forecast from a weather site.
The problem is that the names in the xml changes with the weekdays.

Code: Select all

[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=http://www.yr.no/place/Norge/M%C3%B8re_og_Romsdal/%C3%85lesund/emleim/varsel.xml
RegExp=(?sU)<title>Wednesday<.*/strong> (.*).<
UpdateRate=600
DynamicVariables=1

[MeasureWeekdayNameTomorrow]
Measure=Time
Format=%w
Substitute="0":"Monday","1":"Tuesday","2":"Wednesday","3":"Thursday","4":"Friday","5":"Saturday","6":"Sunday"
DynamicVariables=1

[MeasureTextForecastTomorrow]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSite]
StringIndex=1
[MeasureWeekdayNameTomorrow] gives me the value i need to locate the right place in the xml. The skin works, but i have to manually edit the weekday in the RegExp.

Is there a way to put the value of a measure inside RegExp (or using variables)? I skimmed through the forum and manual without being able to find a solution=/
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing value of a measure inside Regexp?

Post by jsmorley »

If I understand you correctly, I think it would be as simple as:

Code: Select all

[MeasureWeekdayNameTomorrow]
Measure=Time
Format=%w
Substitute="0":"Monday","1":"Tuesday","2":"Wednesday","3":"Thursday","4":"Friday","5":"Saturday","6":"Sunday"

[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=http://www.yr.no/place/Norge/M%C3%B8re_og_Romsdal/%C3%85lesund/emleim/varsel.xml
RegExp=(?sU)<title>[MeasureWeekdayNameTomorrow]<.*/strong> (.*).<
UpdateRate=600
DynamicVariables=1
I assume you are using %w and Substitute instead of just %A to account for possible "locale" language differences on different systems?
Thomasne
Posts: 5
Joined: August 24th, 2014, 7:57 pm

Re: Placing value of a measure inside Regexp?

Post by Thomasne »

But but didn't I try that at some point?!

Thanks a lot, works like a charm :thumbup:

Probably simler methods, but %w and sub gives me what day it is tomorrow. I tried first to use %a and substitute "mon" with "Tuesday" etc, but that gave me the value mondaydaydaydaydaydayday or something like that.

Trying to make my own skins with no programming experience makes me feel like ralph from the simpsons
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing value of a measure inside Regexp?

Post by jsmorley »

Thomasne wrote:But but didn't I try that at some point?!

Thanks a lot, works like a charm :thumbup:

Probably simler methods, but %w and sub gives me what day it is tomorrow. I tried first to use %a and substitute "mon" with "Tuesday" etc, but that gave me the value mondaydaydaydaydaydayday or something like that.

Trying to make my own skins with no programming experience makes me feel like ralph from the simpsons
I think %A (capital A) will return Monday, Tuesday etc. exactly as you want them.
Thomasne
Posts: 5
Joined: August 24th, 2014, 7:57 pm

Re: Placing value of a measure inside Regexp?

Post by Thomasne »

Yes, but on a monday i need the value Tuesday, and the value Wednesday on a tuesday etc. Doesn't %A just give me what day it is today?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Placing value of a measure inside Regexp?

Post by jsmorley »

Thomasne wrote:Yes, but on a monday i need the value Tuesday, and the value Wednesday on a tuesday etc. Doesn't %A just give me what day it is today?
Oh, right... Sorry. Carry on.