It is currently March 28th, 2024, 1:50 pm

Dynamic text that includes measures.

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Dynamic text that includes measures.

Post by kyriakos876 »

Hello everybody,

I have a text meter and a measure that sets the text depending on some variables like so:

Code: Select all

[FollowHoverBarText]
Group=FollowHover
Meter=String
Text=[CalculateHoverHours]:[CalculateHoverMinutes]:[CalculateHoverSeconds]
X=([MeasureFollowHoverBar]+25)
Y=132
StringAlign=Center
FontColor=221,221,221,(19.6*#RDW#)
FontFace=Roboto-Regular
DynamicVariables=1
AntiAlias=1
Hidden=1

[SetFollowHoverBarText]
Group=FollowHover
Measure=Calc
Formula=([MeasureDuration:]*0.[MeasureFollowHoverBar:%,0]/3600)
IfCondition=[SetFollowHoverBarText]>0
IfTrueAction=[!SetOption FollowHoverBarText Text "[CalculateHoverHours]:[CalculateHoverMinutes]:[CalculateHoverSeconds]"]
IfFalseAction=[!SetOption FollowHoverBarText Text "[CalculateHoverMinutes]:[CalculateHoverSeconds]"]
DynamicVariables=1
If I delete that Measure then the Meter displays the correct text that changes dynamically when stuff happens, but when I added that it sets it but the values stay 0:0:0 or 0:0 depending on the case. The text doesn't change. Any ideas why?
Last edited by kyriakos876 on May 18th, 2018, 4:48 pm, edited 1 time in total.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Dynamic text that includes measures.

Post by kyriakos876 »

Well, I feel stupid... I just had to escape each measure with *... How do I deleted a post? Asking for a friend...
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Dynamic text that includes measures.

Post by kyriakos876 »

I just didn't want to open another thread for this so I'm posting here. I have this:

Code: Select all

Substitute="1":"0.1", "2":"0.2", "3":"0.3", "4":"0.4", "5":"0.5", "6":"0.6", "7":"0.7", "8":"0.8", "9":"0.9"
but I want it to change only if 1,2,3,4,... are alone. I don't want 41 to become 0.40.1 for example, what would the correct syntax be here?

Or if there's a way to get from a percentage Measure the outcome like this: 01, 02.... intead of 1,2,3... that would be great too...
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic text that includes measures.

Post by balala »

kyriakos876 wrote:but I want it to change only if 1,2,3,4,... are alone. I don't want 41 to become 0.40.1 for example, what would the correct syntax be here?
Use regular expression substitution:

Code: Select all

RegExpSubstitute=1
Substitute="^(.)$":"0.\1"
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Dynamic text that includes measures.

Post by kyriakos876 »

balala wrote:Use regular expression substitution:

Code: Select all

RegExpSubstitute=1
Substitute="^(.)$":"0.\1"
Turns out I need 1 to be converted to 01 and not 0.1.....
Could you explain to me how does the above code work? The (.) in "^(.)$":"0.\1"stands for every number? and if it does, I don't want it to happen to all numbers... only 1-9. I don't want 79 to become 079 for example.... Thanks in advance.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic text that includes measures.

Post by balala »

kyriakos876 wrote:Turns out I need 1 to be converted to 01 and not 0.1.....
Remove the dot from the Substitute option: Substitute="^(.)$":"0\1".
kyriakos876 wrote:Could you explain to me how does the above code work? The (.) in "^(.)$":"0.\1"stands for every number? and if it does, I don't want it to happen to all numbers... only 1-9. I don't want 79 to become 079 for example.... Thanks in advance.
(.) means one single character, doesn't matter which one (can be digit, letter, or anything else - also see below). The previous ^ and following $ characters mean the beginning and the end of the expression. So, ^(.)$ means: if from the beginning of the expression (^), until its end ($) there is one single character ((.)), a 0 will be added before it (in the substituted expression I put a 0 in front of the \1 expression - \1 means the appropriate capture). For details read the second paragraph here.
If you want to substitute ONLY the numbers a more precise substitution would be: Substitute="^(\d{1})$":"0\1". In this expression \d{1} means one single (due to the {1} value) digit (\d).
More details: https://docs.rainmeter.net/manual/skins/option-types/#RegExp
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Dynamic text that includes measures.

Post by kyriakos876 »

balala wrote:Remove the dot from the Substitute option: Substitute="^(.)$":"0\1".


(.) means one single character, doesn't matter which one (can be digit, letter, or anything else - also see below). The previous ^ and following $ characters mean the beginning and the end of the expression. So, ^(.)$ means: if from the beginning of the expression (^), until its end ($) there is one single character ((.)), a 0 will be added before it (in the substituted expression I put a 0 in front of the \1 expression - \1 means the appropriate capture). For details read the second paragraph here.
If you want to substitute ONLY the numbers a more precise substitution would be: Substitute="^(\d{1})$":"0\1". In this expression \d{1} means one single (due to the {1} value) digit (\d).
More details: https://docs.rainmeter.net/manual/skins/option-types/#RegExp
I saw those but I was looking for something too specific and having little to no experience with regular exrpessions, I couldn't find it :/
Now I understand it and "^(.)$":"0\1" works the way I wanted. Thanks!
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic text that includes measures.

Post by balala »

kyriakos876 wrote:Now I understand it and "^(.)$":"0\1" works the way I wanted. Thanks!
You're welcome. The regular expressions indeed are not to easy, you have to get used to use them. But finally nor impossible isn't.
User avatar
tjhrulz
Developer
Posts: 267
Joined: October 13th, 2016, 1:28 am
Location: Earth
Contact:

Re: Dynamic text that includes measures.

Post by tjhrulz »

balala wrote:You're welcome. The regular expressions indeed are not to easy, you have to get used to use them. But finally nor impossible isn't.
Remember [url=htyps://www.regexr.com]regexr.com[/url] is your friend.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic text that includes measures.

Post by balala »

tjhrulz wrote:Remember [url=htyps://www.regexr.com]regexr.com[/url] is your friend.
There are more such sites. Another example: https://regex101.com/
Post Reply