It is currently May 5th, 2024, 7:53 am

Inline option issue

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Inline option issue

Post by pul53dr1v3r »

i have a meter where max and min temperetaure colors should be different. But in some occasions the color of min gets the color of max temp.
Here are some examples when it occurs:

Image Image

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=[MeasureForecastTempMin2]
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=[MeasureForecastTempMax2]
DynamicVariables=1
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
So, how to fix it (not ro make additional meters and/or measures if possible)?
Last edited by pul53dr1v3r on October 26th, 2019, 2:15 pm, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Inline option issue

Post by eclectic-tech »

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=^.*\|(.+)#deg#
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=^(.+)\|
DynamicVariables=1
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
Your InlinePatterns match everything, so when the values have the same numbers, they get the associated settings applied.

To correct:
Capture the characters after the 'bar symbol' (|) and apply the InLineSetting.
Capture the characters before the bar symbol and apply InlineSetting2.
Then set the 'bar symbol' and #deg# variable to your text color (I used 255,255,255) in 'new' InLineSetting3.

EDIT: Replaced measure values with positions (what I said, but didn't do in my first suggestion... :uhuh: ) and removed unnecessary pattern3.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

InlinePattern is based on Regular Expression.

If you have a pattern that is looking at the value of [Measure1] and that is currently "15", and you have a pattern that is looking at the value of [Measure2] and that is also "15", then both are true. The last one ends up wining them both.

Take a look at an approach like this... It is based on the "position" of the numbers in the string, instead of their "values".

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=([\d]+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|([\d]+)
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
eclectic-tech beat me to it... While his approach is not identical, the idea and result are the same. I'm just not sure why you would ever base this on the "value" of the numbers. It's really just about the "position" of them. The other advantage of not using [SectionVariables] is that you don't need DynamicVariables=1 on it.

So what the regular expressions are saying is:

InlinePattern=([\d]+)\|
( Start capturing [\d] a character set of "digits" + one or more times, and ) stop capturing when you hit \| a pipe character, \escaped since it has the meaning of "OR" in regular expression.

InlinePattern2=\|([\d]+)
Start with \| a pipe character, \escaped since it has the meaning of "OR" in regular expression. Then ( start capturing [\d] a character set of "digits" + one or more times and stop ) capturing when there are no more digits.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

Hi ET, morley. I applied it to my code but:
eclectic-tech wrote: October 25th, 2019, 9:00 pm
unfortunatelly doesn't work. :???:

I just replaced the colors since red is for the max temp.

Current look of the meter:

Code: Select all

[MeterForecastDay1Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign
MeasureName=MeasureForecastTempMax1
MeasureName2=MeasureForecastTempMin1
StringStyle=Normal
InlineSetting=Color | 255,51,51,#colorText2Alpha#
InlinePattern=^.*|([MeasureForecastTempMin2])$
InlineSetting2=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=^([MeasureForecastTempMax2])\|.*$
InlineSetting3=Color | 255,255,255,#colorText2Alpha#
InlinePattern3=.*(\|).*(#deg#)
DynamicVariables=1
FontSize=8
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
jsmorley wrote: October 25th, 2019, 9:03 pm
Doesn't work too. :???:

Code: Select all

[MeterForecastDay1Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign
MeasureName=MeasureForecastTempMax1
MeasureName2=MeasureForecastTempMin1
StringStyle=Normal
InlineSetting=Color | 255,51,51,#colorText2Alpha#
InlinePattern=([\d]+)\|
InlineSetting2=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=\|([\d]+)
FontSize=8
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
This is what your solutions give:
Image
I'm just not sure why you would ever base this on the "value" of the numbers.
It was easier to me since my experience with Regular expressions is just basic(poor). :oops:

And, thanks a lot for the explanation no matter the issue haven't been solved with it.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

Sorry, but mine at least certainly does work...

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
colorText2Alpha=255
deg=°

[MeasureForecastTempMax2]
Measure=Calc
Formula=15

[MeasureForecastTempMin2]
Measure=Calc
Formula=15

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=([\d]+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|([\d]+)
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1

1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

OOOH! I see... I didn't account for the possible - negative symbol in the value.

Try this:

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=([-]*[\d]+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|([-]*[\d]+)
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1

1.jpg


So we look for a character set of [-] negative, zero or more times. We use * so it won't "fail" if the negative symbol isn't there.
You do not have the required permissions to view the files attached to this post.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

jsmorley wrote: October 25th, 2019, 9:59 pm OOOH! I see... I didn't account for the possible - negative symbol in the value.

Try this:

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=([-]*[\d]+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|([-]*[\d]+)
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1


1.jpg



So we look for a character set of [-] negative, zero or more times. We use * so it won't "fail" if the negative symbol isn't there.
Yes, it WORKS now! Thanks a lot. I'll continue reading what i didn't tomorrow since it is very late now.
Great solution, especially that doesn't require using DynamicVariables (at least a bit of performace will be saved).

Will test it later a bit more, just in case.

Thanks to both of you!
Last edited by pul53dr1v3r on October 25th, 2019, 10:11 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

So in that case, I may have over-complexity-complicated things by looking specifically for "digits". I didn't follow my own advice that this is about "position" and not in any way about "value"... Damn me and the horse I rode in on.

Take a look at this:

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=^(.+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|(.+)#deg#
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
Start at the ^ beginning and capture everything until you hit a | pipe.
Start at a | pipe and capture everything until you hit a ° degree symbol.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

jsmorley wrote: October 25th, 2019, 10:10 pm So in that case, I may have over-complexity-complicated things by looking specifically for "digits". I didn't follow my own advice that this is about "position" and not in any way about "value"... Damn me and the horse I rode in on.

Take a look at this:

Code: Select all

[MeterForecastDay2Temp]
Meter=String
MeterStyle=stylePrimaryText | StyleCenterAlign_r
MeasureName=MeasureForecastTempMax2
MeasureName2=MeasureForecastTempMin2
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=^(.+)\|
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=\|(.+)#deg#
Text=%1|%2#deg#
Group=Weather
UpdateDivider=-1
Start at the ^ beginning and capture everything until you hit a | pipe.
Start at a | pipe and capture everything until you hit a ° degree symbol.
I tested this all more thoroughly and it does work no any issue under any circumstances. :great:

I told the last solution is great, but it's just good, this one is so.

My, so to speak, probably the closest approach to this was:

Code: Select all

InlinePattern=^(.*)|
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=.*|(.*)#deg#$
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
but ofc. hadn't worked.

But what the error using (.*) (0 or more occurrencese) instead of (.+) (1 or +) could make in this case, using your latest approach?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

You just need to \escape the | pipe character(s) as that character is reserved in regular expression and means "OR".

Code: Select all

InlinePattern=^(.*)\|
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=.*\|(.*)#deg#$
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
While it won't hurt, the trailing $ is really not needed, as it will stop capturing when it hits #deg#. To be honest, the leading ^ is also not really needed, as it will always start at the beginning of the string. It both cases though, it does no harm, and may make it a bit clearer as to the intent.

There is really no need to .* skip to the \| in InlinePattern2. Regular expression will by its nature skip to the first instance of anything you are trying to "match" from the start of the string. Again, does no harm...

The difference between * (zero or more) and + (one or more) is not really important in this case, although I tend to use + when (capturing) in InlinePattern, as the logic of "color this red if there are none of them" offends me at some level...

Probably the most technically perfect form of this is:

Code: Select all

InlinePattern=(.+)\|
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=\|(.+)#deg#
InlineSetting2=Color | 255,51,51,#colorText2Alpha#