It is currently April 26th, 2024, 7:08 am

Weird MouseOver behavior.

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weird MouseOver behavior.

Post by jsmorley »

kyriakos876 wrote: October 20th, 2018, 11:13 am Hello, I didn't want to open another thread because it's similar to the above post but escaping doesn't do the trick this time around.
Here's my issue...

This doesn't work:

Code: Select all

[Variables]
Shortcut1Name=Something

[Shortcut1]
Meter=String
Text=[#CurrentSection[#Name]]
FontColor=255,255,255
FontSize=20
Antialias=1
DynamicVariables=1
But this does:

Code: Select all

[Variables]
NameShortcut1=Something

[Shortcut1]
Meter=String
Text=[#Name[#CurrentSection]]
FontColor=255,255,255
FontSize=20
Antialias=1
DynamicVariables=1
What's up? Is it parsing from right to left, so because there's no Name variable it can't process it?
Obviously neither really works, since #Name# is not defined.

There are some known issues with nesting #CurrentSection# with other variables, it has to do with the order that things are parsed in, as you note. I'm not clear on the details, perhaps Brian can weigh in at some point.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Weird MouseOver behavior.

Post by kyriakos876 »

jsmorley wrote: October 20th, 2018, 1:25 pm Obviously neither really works, since #Name# is not defined.

There are some known issues with nesting #CurrentSection# with other variables, it has to do with the order that things are parsed in, as you note. I'm not clear on the details, perhaps Brian can weigh in at some point.
The second one works.... Notice that I changed the name of the variable as well. So I suppose it's parsed from inside to outise...
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weird MouseOver behavior.

Post by jsmorley »

kyriakos876 wrote: October 20th, 2018, 1:46 pm The second one works.... Notice that I changed the name of the variable as well.
It only works by accident. Since #Name# is not defined, it is treated as text, almost as if you defined Name=Name in [Variables].
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Weird MouseOver behavior.

Post by kyriakos876 »

jsmorley wrote: October 20th, 2018, 1:48 pm It only works by accident. Since #Name# is not defined, it is treated as text, almost as if you defined Name=Name in [Variables].
Alright... I'll work with the accident then until there is more light in the tunnel
User avatar
Brian
Developer
Posts: 2684
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Weird MouseOver behavior.

Post by Brian »

Nested variables are parsed "inside to outside", so that is why your second example works, but the first one does not.

Example 1:
#Name doesn't exist and no replacement is made, so the final outer variable becomes #CurrentSection[#Name] which obviously will not work.

Example 2:
#CurrentSection get replaced with "Shortcut1" which is then appended to "Name" making [#NameShortcut1] which then gets replaced with "Something".

It's a little tricky to wrap your head around, but this example is one of the driving forces of nested variables.

-Brian
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Weird MouseOver behavior.

Post by kyriakos876 »

Brian wrote: October 20th, 2018, 2:58 pm Nested variables are parsed "inside to outside", so that is why your second example works, but the first one does not.

Example 1:
#Name doesn't exist and no replacement is made, so the final outer variable becomes #CurrentSection[#Name] which obviously will not work.

Example 2:
#CurrentSection get replaced with "Shortcut1" which is then appended to "Name" making [#NameShortcut1] which then gets replaced with "Something".

It's a little tricky to wrap your head around, but this example is one of the driving forces of nested variables.

-Brian
Oh okay... so my assumption above
kyriakos876 wrote: October 20th, 2018, 1:46 pm The second one works.... Notice that I changed the name of the variable as well. So I suppose it's parsed from inside to outise...
was correct... Okay, good to know that's certain!
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weird MouseOver behavior.

Post by jsmorley »

I think what you want in the two cases is:

Code: Select all

[Variables]
Shortcut1Name=Something

[Shortcut1]
Meter=String
Text=[#[#CurrentSection]Name]
FontColor=255,255,255
SolidColor=0,0,0,1
FontSize=20
Antialias=1
DynamicVariables=1



[Variables]
NameShortcut1=Something

[Shortcut1]
Meter=String
Text=[#Name[#CurrentSection]]
FontColor=255,255,255
SolidColor=0,0,0,1
FontSize=20
Antialias=1
DynamicVariables=1
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Weird MouseOver behavior.

Post by kyriakos876 »

jsmorley wrote: October 20th, 2018, 3:19 pm I think what you want in the two cases is:

Code: Select all

.
.
.
Text=[#[#CurrentSection]Name]
.
.
.
I didn't know that syntax was possible... It makes more sense this way anyway... I just didn't see it in the examples given here:
https://docs.rainmeter.net/manual-beta/variables/nesting-variables/

And I didn't think that there were more syntax options... Maybe I should have because it says "Examples" and not "Nothing else than that"

Thanks for your solution!
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weird MouseOver behavior.

Post by jsmorley »

kyriakos876 wrote: October 20th, 2018, 3:29 pm I didn't know that syntax was possible... It makes more sense this way anyway... I just didn't see it in the examples given here:
https://docs.rainmeter.net/manual-beta/variables/nesting-variables/

And I didn't think that there were more syntax options... Maybe I should have because it says "Examples" and not "Nothing else than that"

Thanks for your solution!
It's all predicated on the fact that nested variables are parsed from the "inside out". It will start with the most inside variable, resolve it, then start working out. Anything that isn't a valid variable is treated as "text". At the end, the entire thing is evaluated to see if it matches an existing variable name, and if so, the value is returned.