Escaping variables can be easily done in Rainmeter, by adding * at the start and end of the variable name, but how can I escape measure references of the form %N, where N is a number? In my feed skin, which currently also displays the content of the posts here on Rainmeter forums, whenever the content is displayed, literal stuff like %1 or %2 from the post are replaced with the measure references that I use in the meter showing the post. Sure, I can reference the measures as [section variables], but that requires constanty updating them with a !SetOption bang, while %1, %2 and such references don't need this extra step.
Is there an easy way of escaping %N references, or does the * method work with them too? Is this even possible?
NOTE: You can test the above if you have a feed skin that displays the content of the post from Rainmeter and you also use a %N measure reference in the meter that shows the content, by the way. Also, this doesn't have anything to do with character reference decoding, since replacing %N with the value of that measure in your skin is done at display time (i.e. when character references are decoded anyway, for easy human readability).
It is currently April 25th, 2024, 6:29 am
Escaping %N at display time
-
- Rainmeter Sage
- Posts: 7157
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Escaping %N at display time
The %1, %2 ... %N tokens used with MeasureName to bind measures to meters are not variables, and cannot be escaped.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Escaping %N at display time
So am I to understand that what you are saying is that if you have a meter that uses MeasureName and %1 in the Text option, and in the literal text that the meter is trying to display there is actually a literal "%1" in it, that is being replaced by the measure value that MeasureName is referencing?
I'm not sure I see a way to avoid that... Guess you could use a RegExpSubstitute to change the % to something else if it is before a number.
I'm not sure I see a way to avoid that... Guess you could use a RegExpSubstitute to change the % to something else if it is before a number.
-
- Rainmeter Sage
- Posts: 7157
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Escaping %N at display time
Ok, I get it. But to clear things up on what I was referring to (since you didn't have any idea what I was talking about), here is my skin suite:
[Removed]
Be aware that it loads one of the included layouts, so save your current layout if needed. Since the work on the Feeds skin is not yet finished, this skin has to be loaded manually (i.e. it isn't loaded with the layout yet). Scroll back to feed #1 or #2 (i.e. my post, at this moment) from site #6 (i.e. Rainmeter) when hovering over the white text, and you'll see what I mean, since I intentionally left an %1 roaming free in my posts.
NOTE: I already escaped Rainmeter variable references in my skin - you can check out the regex Finisher from the code - that's why I was asking this...
Last edited by Yincognito on March 9th, 2019, 6:51 pm, edited 2 times in total.
-
- Rainmeter Sage
- Posts: 7157
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Escaping %N at display time
Yep, something like that. Interestingly, %2 is not replaced, only %1 - not sure why or what I am missing here...jsmorley wrote: ↑March 9th, 2019, 5:52 pmSo am I to understand that what you are saying is that if you have a meter that uses MeasureName and %1 in the Text option, and in the literal text that the meter is trying to display there is actually a literal "%1" in it, that is being replaced by the measure value that MeasureName is referencing
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Escaping %N at display time
You might try something like:
Without the Substitute, you get This doesn't, This has This doesn't in it
So I'm just inserting an invisible control character (BEL) between the % and the 1.
Then you get This doesn't, this has %1 in it
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureString1]
Measure=String
String=This doesn't
[MeasureString2]
Measure=String
String=This has %1 in it
RegExpSubstitute=1
Substitute="%([\d]+)":"%[\x7]\1"
[MeterOne]
Meter=String
MeasureName=MeasureString1
MeasureName2=MeasureString2
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=%1, %2
So I'm just inserting an invisible control character (BEL) between the % and the 1.
Then you get This doesn't, this has %1 in it
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Escaping %N at display time
Trust me, I am NEVER going to download and try to figure out this skin you are building...
I would far prefer that the tears be yours, not mine...
I would far prefer that the tears be yours, not mine...
-
- Rainmeter Sage
- Posts: 7157
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Escaping %N at display time
Thanks - that's what I was looking for. Should have thought about that myself.
I told you already, there will be NO TEARS involved at all. Actually, it's a lot of joy, since apart from some minor issues that need to be solved along the way, everything works even better than I expected when I started to rewrite my "old" Feeds skin from a couple of years back.
I didn't upload it for you to solve my problems, jsmorley. I'm a big boy, I can solve things on my own, LOL - I just needed an alternative idea. I uploaded it so you can see what I was talking about - since you wrote that you can't understand what I'm trying to say in your first reply, before editing it.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Escaping %N at display time
I'm always glad to help, but I prefer a clear explanation of what you are trying to solve, or a simple, pared-down example that demonstrates it. I generally won't ever download some huge skin suite to try and track down what someone is asking about.
-
- Rainmeter Sage
- Posts: 7157
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Escaping %N at display time
Of course. I would do the same. Generally, I'm also trying to post a basic example on what is happening, but in some cases it isn't possible due to dependencies in the skin or skin suite itself. In those cases, I try to explain things verbally and hope that someone would be able to understand it. Sometimes I'm more "convoluted" in my posts, but that's only because I try to explain all the aspects of the issue I talk about.