It is currently March 29th, 2024, 3:22 pm

[BUG?]Escaped CURRENTSECTION variable

Report bugs with the Rainmeter application and suggest features.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

[BUG?]Escaped CURRENTSECTION variable

Post by death.crafter »

A while back in a previous thread I reported about multiple use of CURRENTSECTION involving inline lua. That problem was indeed solved in revision 3493.

But I notices another weird behavior. When CURRENTSECTION is used as an escaped variable, [#*CURRENTSECTION*], it's value is empty when used with mouse actions.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
String=Meter5
LMUA=[#*CURRENTSECTION*]
RMUA=[#*String*]

[Meter5]
Meter=Image
H=30
W=30
SolidColor=00ffff
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Example "#LMUA#"][!Log "[#Example]"]
While #RMUA# will log the correct value, #LMUA# wouldn't.
from the Realm of Death
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Active Colors »

Oh, we were thinking in the same direction at the same time. I've replied to your previous thread the explanation without noticing that you've created a new thread. https://forum.rainmeter.net/viewtopic.php?f=14&t=37775&start=10#p192626.

What I've said there is pretty much what you have described here except there I've indicated an additional detail which I will repeat here as well for the sake of consistency:
— The issue you have described actually works if you use [#*CURRENTSECTION*] NOT in bangs. So, in places like measures it will work.
User avatar
Yincognito
Rainmeter Sage
Posts: 7031
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Yincognito »

This is another form of this behavior here. Not sure it can be properly solved, unfortunately... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG?]Escaped CURRENTSECTION variable

Post by death.crafter »

Active Colors wrote: June 30th, 2021, 10:38 am First of all, notice that Rainmeter in About-Skins window reports the [#*CURRENTSECTION*] without the asterisks. (this behavior is explained here )

• Escaped variables https://forum.rainmeter.net/viewtopic.php?f=14&p=191846#p191846

Code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
Test=[#*CURRENTSECTION*]

[5]
Measure=Calc
Formula=([#Test])
DynamicVariables=1

[Meter5]
Meter=Image
H=30
W=30
SolidColor=00ffff
MouseOverAction=[!Log "Test is [#Test]"][!Log "Measure 5 is [&5]"]
DynamicVariables=1
I will be quoting you here instead.

Yes, have considered the first point you made before opening an different thread.

When we use [#*CURRENTSECTION*], the variables becomes [#CURRENTSECTION], but that is also the value used when the variable is used in the bangs. For example, [!Log "#Variable#"] becomes [!Log "[#CURRENTSECTION]"] to the parser.

The second thread you linked is my very own thread, that was when I did not understand the parsing method, but now that I do, I can say for sure that it has nothing to do with that. In that thread I wanted the variables "not to be parsed".

So let's consider the case.

When we use:

Code: Select all

[Variables]
CrrntSection1=[#CURRENTSECTION]
CrrntSection2=[#*CURRENTSECTION*]
CrrntSection3=[#**CURRENTSECTION**]
CrrntSection4=[#***CURRENTSECTION***]
[Meter]
...
LeftMouseUpAction=[!Log "#CrrntSection2#"]
Let's iterate through the CrrntSection{N} variables and see the expected and logged results:
  1. Expected Value=Variables, Real Value=Variables
  • Expected Value=Meter, Real Value=' '
  • Expected Value=Meter, Real Value=' '
  • Expected Value=[#CURRENTSECTION], Real Value=[#CURRENTSECTION]
Well that's the results based on how the parsing of bangs take place.

But quoting Brian here,
Brian wrote: April 23rd, 2021, 6:33 am For example, in your case above, when the IfConditions actions are read, the #CURRENTSECTIONINDEX# variable is replaced with [&Script:SectionIndex('[#CURRENTSECTION]','last','(<x>)')] (note the *'s were removed in this step). Normally, the current section special processing would kick in and parse the [#CURRENTSECTION] variable here, but that does not happen since the action only re-evaluates section/nested variables when the action is executed. By that time, section tracking is lost and nothing is retrieved. This particular case seems to be related to variables referencing other variables containing the current section variable.

Unfortunately, this current section issue has been around since we introduced the variable. Fixing it for all the special cases has been a challenge.

-Brian
I guess this problem is a pain ita. So I would not prod it further. I just wanted to make my point clearer.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7031
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Yincognito »

death.crafter wrote: June 30th, 2021, 1:08 pmI guess this problem is a pain ita. So I would not prod it further. I just wanted to make my point clearer.
In theory, it could be possible to make a recursive Initialization Lua function that would parse the skin (@Includes, meter styles, etc.) and get the values of #CURRENTSECTION# for each of its (nested, escaped, plain, etc.) occurrences in a table in order to be used in an actual Lua inline function through replacing, but then that would be reinventing the wheel, a bit of an effort and wouldn't be able to replace Rainmeter's own skin parsing, especially when the parsed parts are not connected to Lua in any way.

This would be possible for our "current section index" Lua implementations though - there it's only the effort to consider and nothing else... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Active Colors »

death.crafter wrote: June 30th, 2021, 1:08 pm I can say for sure that it has nothing to do with that.
...
I just wanted to make my point clearer.
Your point is clear. But I wouldn't be so assertive that it has nothing to do with that because:
Brian wrote: April 23rd, 2021, 6:33 am This issue is specific to the CURRENTSECTION variable and is caused by how/when bangs are parsed.
...
The CURRENTSECTION variable is the only variable that needs special parsing throughout Rainmeter, both in its regular #CURRENTSECTION# and nested [#CURRENTSECTION] forms.
...
Here is a similar test skin that shows the CURRENTSECTION problem with a basic OnUpdateAction:
...
Unfortunately, this current section issue has been around since we introduced the variable. Fixing it for all the special cases has been a challenge.
Taken from here: https://forum.rainmeter.net/viewtopic.php?f=14&t=37403#p190362
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG?]Escaped CURRENTSECTION variable

Post by death.crafter »

Active Colors wrote: June 30th, 2021, 1:43 pm Your point is clear. But I wouldn't be so assertive that it has nothing to do with that because:
Ohh no.. You misunderstood. Or may be I explained wrong. I was referring to the purpose of the thread and reply. And btw you quoted the same post :lol:
Yincognito wrote: June 30th, 2021, 1:41 pm In theory, it could be possible to make a recursive Initialization Lua function that would parse the skin (@Includes, meter styles, etc.) and get the values of #CURRENTSECTION# for each of its (nested, escaped, plain, etc.) occurrences in a table in order to be used in an actual Lua inline function through replacing, but then that would be reinventing the wheel, a bit of an effort and wouldn't be able to replace Rainmeter's own skin parsing, especially when the parsed parts are not connected to Lua in any way.

This would be possible for our "current section index" Lua implementations though - there it's only the effort to consider and nothing else... :???:
Me who's lazy af:
TerioUmmGIF.gif
On a second note you can easily use the variable in focus in measures (confirmed by ActiveColors), and for meters you have got the ultimate MeterStyle. But you already know that. :P
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7031
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Yincognito »

death.crafter wrote: June 30th, 2021, 1:55 pmMe who's lazy af:
TerioUmmGIF.gif
Don't worry, I can take care of that. I'm lazy as well, but when I put my mind to it to do as I want, that takes priority over my laziness. :D
Human nature is almost as strange as the CURRENTSECTION behavior, it seems...
death.crafter wrote: June 30th, 2021, 1:55 pmOn a second note you can easily use the variable in focus in measures (confirmed by ActiveColors), and for meters you have got the ultimate MeterStyle. But you already know that. :P
Can you pinpoint exactly to what " variable in focus in measures (confirmed by ActiveColors)" are you referring to? I might know some things, but when there are multiple posts describing stuff, I may need some guidance. By the way, I already thought of an easy way to do it, so I'm curious if what you refer to is easier than my idea or not.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [BUG?]Escaped CURRENTSECTION variable

Post by Active Colors »

death.crafter wrote: June 30th, 2021, 1:55 pm And btw you quoted the same post :lol:
tenor.gif
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [BUG?]Escaped CURRENTSECTION variable

Post by death.crafter »

Yincognito wrote: June 30th, 2021, 2:07 pm Don't worry, I can take care of that. I'm lazy as well, but when I put my mind to it to do as I want, that takes priority over my laziness. :D
Human nature is almost as strange as the CURRENTSECTION behavior, it seems...
Lol... True tho.
Yincognito wrote: June 30th, 2021, 2:07 pm Can you pinpoint exactly to what " variable in focus in measures (confirmed by ActiveColors)" are you referring to? I might know some things, but when there are multiple posts describing stuff, I may need some guidance. By the way, I already thought of an easy way to do it, so I'm curious if what you refer to is easier than my idea or not.
https://forum.rainmeter.net/viewtopic.php?p=192641#p192626
from the Realm of Death