It is currently March 29th, 2024, 2:11 pm

!WriteKeyValue and Text Meter Empty String vs Space [solved]

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

!WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by Mor3bane »

I have an intrinsic query.

In the !WriteKeyValue Bang when I do the empty string value e.g. " " with the space. The updated skin does not show the space. Is there a place holder type of value I can put between the double quotes?

#nbsp# does not seem to work and the effect is broken e.g. when the key value equals "#nbsp#" it does not work and the key value remains set as a previous value.

Inputs appreciated.
Last edited by Mor3bane on November 29th, 2019, 7:46 am, edited 1 time in total.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: !WriteKeyValue and Text Meter Empty String vs Space

Post by Mor3bane »

Oooh. I just figured it out.

Magic Quotes. But in this case - Double-Double Magic Quotes around the empty space: """" """"
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !WriteKeyValue and Text Meter Empty String vs Space

Post by balala »

Mor3bane wrote: November 29th, 2019, 7:41 am But in this case - Double-Double Magic Quotes around the empty space: """" """"
No, that's not a double - double magic quotes, but a simple quote, included into a pair of magic quotes, which has a triple quote. In the following expression, green are the magic quotes and red the simple quote. Those are related to each other as it follows: """" """".
Details: https://docs.rainmeter.net/manual/skins/option-types/#MagicQuotes
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: !WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by Mor3bane »

Well that was how I saw it in my head that the magic quotes are the outermost double-double with the innermost being the initial double quotes.

It just sounded silly so i said that way to be humorous or coy, but unintentionally sounded like i did not understand the concept. Perhaps i still do, but ya, i get the idea.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: !WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by jsmorley »

Yes, Magic Quotes are always 3.

They are used to unambiguously tell Rainmeter that the first """ is the starting quote for a bang parameter of any kind, and the last """ is the ending quote for the parameter. This is only used, but very important, when the parameter itself has literal quotes anywhere in it, as without Magic Quotes that would drive the routines that are "parsing" the parameters crazy.

Magic Quotes are only used in the context of a parameter for a bang that contains literal quote characters. They are never needed on any option value.

If you are using them for instance in a parameter for a !SetOption setting a Substitute:

LeftMouseUpAction=[!SetOption MyMeasure Substitute """Hello":"Goodbye"""]

Then you use 3, since the Substitute option itself uses quotes, and you need to unambiguously tell Rainmeter where that !SetOption parameter starts and ends.

If you are using them in a !WriteKeyValue bang, and you INTEND for starting and ending quotes to be "written", then you need 3 PLUS the "literal" quote:

LeftMouseUpAction=[!WritekeyValue Variables MyVar """"starting, ending and embedded "quotes" here""""]

This will create

MyVar="starting, ending and embedded "quotes" here"

If you DON'T INTEND for starting and ending quotes to be "written", you just use the 3 Magic Quotes:

LeftMouseUpAction=[!WritekeyValue Variables MyVar """embedded "quotes" here"""]

This will create

MyVar=embedded "quotes" here
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by balala »

jsmorley wrote: November 30th, 2019, 2:46 am LeftMouseUpAction=[!SetOption MyMeasure Substitute """Hello":"Goodbye"""]

Then you use 3, since the Substitute option itself uses quotes, and you need to unambiguously tell Rainmeter where that !SetOption parameter starts and ends.
:o This again surprised me a lot. :o

I never tried this, but I would have say that a [!SetOption MyMeasure Substitute """"Hello":"Goodbye""""] form of this bang should work, but certainly not [!SetOption MyMeasure Substitute """Hello":"Goodbye"""]. The problem with this is that in my opinion, this doesn't have a starting and an ending quote, because there are three, which are the magic quotes and one more should be used, which would belong to the Substitute option itself.
But it does work as you posted. In fact if the substitution is posted directly as an option on the measure, not being set through a !SetOption bang, the Substitute=Hello":"Goodbye (with no starting and ending quotes - or how those could be named) is also working.
As I said more times before, there still are a lot of thing to be learned. Proceeding with this...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: !WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by jsmorley »

balala wrote: November 30th, 2019, 2:48 pm :o This again surprised me a lot. :o

I never tried this, but I would have say that a [!SetOption MyMeasure Substitute """"Hello":"Goodbye""""] form of this bang should work, but certainly not [!SetOption MyMeasure Substitute """Hello":"Goodbye"""]. The problem with this is that in my opinion, this doesn't have a starting and an ending quote, because there are three, which are the magic quotes and one more should be used, which would belong to the Substitute option itself.
But it does work as you posted. In fact if the substitution is posted directly as an option on the measure, not being set through a !SetOption bang, the Substitute=Hello":"Goodbye (with no starting and ending quotes - or how those could be named) is also working.
As I said more times before, there still are a lot of thing to be learned. Proceeding with this...
It's not entirely intuitive, but perhaps the best way to think about Magic Quotes is that they "replace" a potentially ambiguous starting or ending double-quote with an unambiguous "special" starting or ending double-quote. The one double-quote that is required, like for Substitute, is still sent, but it is sent after the "parsing" of the bang parameter is done, and all confusion about what is the start and end of the parameter is removed.

Adding to some confusion is the fact that we made the Substitute option "smart" enough to assume the starting and ending quotes if they are missing, as you noted when you used it without them in a direct "option". Most text options are this way, which is why you can use Text=Hello World, and don't need Text="Hello World" even though your inner programmer is screaming that strings need to be enclosed in a quotes. They don't in Rainmeter. EVERYTHING after the equal = sign in an option is really a "string" and Rainmeter knows that.

If you want to be really befuddled, chew on this one:

Code: Select all

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

[Variables]

[MeasureString]
Measure=String
String=""I said Hello""

[MeterString]
Meter=String
MeasureName=MeasureString
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
LeftMouseUpAction=[!SetOption MeasureString Substitute """Hello":"Goodbye",'"':"'"""]

GIF.gif


So there are several things this points out.

1) You don't need "quotes" around any textual option in Rainmeter. Any pairs of starting AND ending quotes you put on them are just thrown away.

Text="Hello World" is pointless and a waste of time. The starting and ending quotes on a textual option are always "assumed".

However, if you want to DISPLAY starting and ending quotes, you will need to use ""two"". This is because the outer set are thrown away, and that allows the inner set to become a "literal".

Note that on a textual option, any starting quote without an ending quote, or an ending quote without a starting quote, are ALWAYS treated as a "literal". So Text="Hello World or Text=Hello World" will display with the starting or ending quote. Functional starting and ending quotes are always "pairs" in Rainmeter.

2) With Substitute, you can alternate " double-quote and ' single-quote to tell Substitute to find and replace double-quotes, without just completely confusing it. So to replace all double-quotes with single-quotes, it would be Substitute='"':"'"

3) You don't want to add the starting and ending quotes to the Substitute command in a bang. The REQUIRED Magic Quotes will play this role!
LeftMouseUpAction=[!SetOption MeasureString Substitute """Hello":"Goodbye",'"':"'"""]

What Rainmeter does is evaluate the bang, and in this case says "Okay, I see the starting and ending Magic Quotes, so now I know for sure where the parameter starts and ends. Any other quotes in between must be literals! Now I can replace those Magic Quotes with one double-quote." Then it uses !SetOption to set the Substitute command as if it were Substitute="Hello":"Goodbye",'"':"'", as if it were just the standard way of defining that option on a measure.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !WriteKeyValue and Text Meter Empty String vs Space [solved]

Post by balala »

jsmorley wrote: November 30th, 2019, 3:07 pm Adding to some confusion is the fact that we made the Substitute option "smart" enough to assume the starting and ending quotes if they are missing, as you noted when you used it without them in a direct "option". Most text options are this way, which is why you can use Text=Hello World, and don't need Text="Hello World" even though your inner programmer is screaming that strings need to be enclosed in a quotes. They don't in Rainmeter. EVERYTHING after the equal = sign in an option is really a "string" and Rainmeter knows that.
Two remarks: :o and :jawdrop
But it's entirely logical. I knew the double-quotes are not required around the parameters of options, but wouldn't think nor the Substitution doesn't require them.
jsmorley wrote: November 30th, 2019, 3:07 pm 1) You don't need "quotes" around any textual option in Rainmeter. Any pairs of starting AND ending quotes you put on them are just thrown away.

Text="Hello World" is pointless and a waste of time. The starting and ending quotes on a textual option are always "assumed".

However, if you want to DISPLAY starting and ending quotes, you will need to use ""two"". This is because the outer set are thrown away, and that allows the inner set to become a "literal".
Yes, I knew this.
jsmorley wrote: November 30th, 2019, 3:07 pm 2) With Substitute, you can alternate " double-quote and ' single-quote to tell Substitute to find and replace double-quotes, without just completely confusing it. So to replace all double-quotes with single-quotes, it would be Substitute='"':"'"
Yes and even more, single-quotes can be used either around the pattern or the replacement, but not both.
jsmorley wrote: November 30th, 2019, 3:07 pm 3) You don't want to add the starting and ending quotes to the Substitute command in a bang. The REQUIRED Magic Quotes will play this role!
LeftMouseUpAction=[!SetOption MeasureString Substitute """Hello":"Goodbye",'"':"'"""]

What Rainmeter does is evaluate the bang, and in this case says "Okay, I see the starting and ending Magic Quotes, so now I know for sure where the parameter starts and ends. Any other quotes in between must be literals! Now I can replace those Magic Quotes with one double-quote." Then it uses !SetOption to set the Substitute command as if it were Substitute="Hello":"Goodbye",'"':"'", as if it were just the standard way of defining that option on a measure.
This is something new, at least for me. Didn't know about this. But makes sense.

Again thank you for the information. Good to be known.