It is currently April 19th, 2024, 2:03 pm

Escaping %N at display time

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Escaping %N at display time

Post by Yincognito »

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).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Escaping %N at display time

Post by jsmorley »

The %1, %2 ... %N tokens used with MeasureName to bind measures to meters are not variables, and cannot be escaped.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Escaping %N at display time

Post by jsmorley »

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.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Escaping %N at display time

Post by Yincognito »

jsmorley wrote: March 9th, 2019, 5:42 pm The %1, %2 ... %N tokens used with MeasureName to bind measures to meters are not variables, and cannot be escaped.
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.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Escaping %N at display time

Post by Yincognito »

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
Yep, something like that. Interestingly, %2 is not replaced, only %1 - not sure why or what I am missing here...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Escaping %N at display time

Post by jsmorley »

You might try something like:

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
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
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Escaping %N at display time

Post by jsmorley »

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...
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Escaping %N at display time

Post by Yincognito »

jsmorley wrote: March 9th, 2019, 6:02 pmYou 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
Thanks - that's what I was looking for. Should have thought about that myself. :oops:
jsmorley wrote: March 9th, 2019, 6:04 pm 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 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.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Escaping %N at display time

Post by jsmorley »

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.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Escaping %N at display time

Post by Yincognito »

jsmorley wrote: March 9th, 2019, 6:24 pm 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.
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.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth