It is currently September 16th, 2024, 7:05 pm

Nested Conditions + Formulas

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16549
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Nested Conditions + Formulas

Post by balala »

sl23 wrote: July 21st, 2024, 8:05 pm A [MeasureName] is that considered a Variable too? I mean if used as a reference such as X=[MeasureName:]
No, at all. [MeasureName] is always a measure. In the X=[MeasureName:] expression, [MeasureName:] is a section variable, being in fact the numeric value of the [MeasureName] measure.

I hope the following short code can let you understand the nesting variables:

Code: Select all

[Variables]
Variable1=12
Variable2=34
Num=1

[Measure1]
Measure=Calc
Formula=2

[MeterString]
Meter=STRING
MeasureName=Measure1
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=Left
AntiAlias=1
Text=Variable#Num#: [#Variable[#Num]]#CRLF#Variable%1: [#Variable[&Measure1]] or [#Variable[&Measure[#Num]]]
See there are three variables: Variable1, Variable2 and Num and a measure ([Measure1]). In the Text option of the [MeterString] meter, you get the followings:
  • [#Variable[#Num]] - The value of the [#Num] variable (same as #Num#) is 1. This is used into the [#Variable[#Num]] syntax, where the red colored [#Num] is replaced by 1, then the [#Variable1] is resolved as 12 (#Variable1#).
  • [#Variable[&Measure1]] - The first element resolved here is [&Measure1] (which is the same as [Measure1]). This is replaced by 2 (the value of the [Measure1] measure). Then [#Variable2] is resolved as 34, this being in fact equal to #Variable2#.
  • [#Variable[&Measure[#Num]]] - In this expression, the first element resolved is [#Num] (same as #Num#). Rainmeter resolves this as being 1 (the value of the Num variable). This is followed by the [&Measure[#Num]] expression, which when the above applies becomes [&Measure1] (same as [Measure1]). Finally based on the above described steps, the [#Variable[&Measure[#Num]]] expression is resolved as [#Variable[&Measure1]] = [#Variable2] = 34.
Complicated? Don't think, but definitely have to dive into it a little bit, to try it out, altering the above expressions. No rush: try to dissect it at your own pace.

Hope I didn't confuse you even more. Feel free to come back if further questions arise.
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Yincognito wrote: July 21st, 2024, 8:36 pm CURRENTSECTION is just a variable holding the name of the current section (i.e. a string like any other), and that's why the [# part is needed for such a variable when nested. It does not represent the value of that section (or that section itself, for that matter), in order to require the [& part when nested.
I understand the most of that, just the last part about the [& isn't understood here, is it purely for referencing a MeasureName section? Or only when it is nested?

Quite the contrary, it's absolutely logical. The [&Section] and [#Variable] are the alternative syntax for [Section] and #Variable#, especially (but not limited to) when nested. So basically you can use either of the syntaxes in normal usage, but you must use the nested syntax when these elements are nested.
Logical if you understand it! :p
But, yes I see it now you explain it. But when you don't know, it makes it a complete guess work trying to figure out why it works.


Hidden=([#[#CURRENTSECTION]Stat]=1 ? 1 : 0)
Why:
- we have nested stuff, so we must use the nested syntax for everything nested
- we want the #CURRENTSECTION# name variable aka 1, which in nexted form is [#CURRENTSECTION]
- we want to insert the above before the literal string Stat, to make it 1Stat which is also a variable, so [#[#CURRENTSECTION]Stat]
Or, step by step:
- [#...Stat]
- ... is [#CURRENTSECTION] for 1
- thus the thinking process should be [#...Stat] -> [#[#CURRENTSECTION]Stat]
Your mistakes:
- not enclosing #CURRENTSECTION between square brackets for the nested syntax
- using [#Stat] despite the fact that Stat is not a variable, but a literal string which doesn't need any syntax around it
- since 1Stat is just a variable and not a measure, the : part for a measure's number value is not needed
I swear to god I tried that, because that was the logical conclusion to me! I probably had a different part incorrect, dunno now.
Thank you, thank you, thank you, for explaining and helping me understand, even if it was to get me off your back! lol

So to be clear, is #CURRENTSECTION# the same as [#CURRENTSECTION]?
If so, now I understand death.crafters comment about it. I hadn't a clue what he was on about at that time!

It took me some time to understand the point of Variables and how to use them, but once I did, I was well away, I'm just trying to expand that and learn nested variables now. Thanks to balala and yourself for the explanations. :thumbup:
57686174 77696C6C 6265 77696C6C 6265
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Thanks for that balala :thumbup:
That was a great explanation and example, but...

I see what's going on, taking a bit of thought to get my head around it, as it did with plain variables. But I'm seeing how it works now.
My only issue is why the meter text displays:
Variable1: 12
Variable2: [#Variable0] or [#Variable0]

Although I can follow it, the first line is correct, but shouldn't the second line display:
Variable2: 34 or 34

I get the first display which doesn't resolve the variables of the second line.
Last edited by sl23 on July 21st, 2024, 9:12 pm, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Nested Conditions + Formulas

Post by Yincognito »

sl23 wrote: July 21st, 2024, 8:53 pmSo to be clear, is #CURRENTSECTION# the same as [#CURRENTSECTION]?
Yes, precisely.
sl23 wrote: July 21st, 2024, 8:53 pmI understand the most of that, just the last part about the [& isn't understood here, is it purely for referencing a MeasureName section? Or only when it is nested?
Like explained in the other paragraph, you can use either [SomeMeasure] or [&SomeMeasure] to refer to the value of that measure, but you must use [&SomeMeasure] when it is part of some nested construct (irrespective of its "nesting level", so to speak).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Ok that's great, thanks for confirming, and to you both for the details. It's cleared up a lot of confusion and frustration! :lol: :thumbup:
Hopefully, now I get it I won't ask so many questions about it!
57686174 77696C6C 6265 77696C6C 6265
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

There is another question...
Why do you need to use this:
[#[#CURRENTSECTION]]

Here's a meter as an example:

Code: Select all

[1Stat]
Meter=Shape
MeterStyle=sBar2
Shape2=Rectangle     0, 0, ([#[#CURRENTSECTION]]=1?0:#BarW#), ([&m[#CURRENTSECTION]:]/100*(-#BarH#)) | StrokeWidth 0 | Fill Color [#C[#CURRENTSECTION]],#BarAlphe#
Shape3=Rectangle 0, (([&m[#CURRENTSECTION]:]/100*(-#BarH#)-1)), ([#[#CURRENTSECTION]]=1?0:#BarW#), 2 | StrokeWidth 0 | Fill Color [#C[#CURRENTSECTION]]
ToolTipText=CPU: [&m[#CURRENTSECTION]:]%
X=0
I think I get it actually. The [#CURRENTSECTION] gets the Section name and the [# ] Makes it get the Variable with that name, is that right?
Last edited by sl23 on July 21st, 2024, 9:20 pm, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Nested Conditions + Formulas

Post by Yincognito »

sl23 wrote: July 21st, 2024, 9:11 pmMy only issue is why the meter text displays:
Variable1: 12
Variable2: [#Variable0] or [#Variable0]

Although I can follow it, the first line is correct, but shouldn't the second line display:
Variable2: 34 or 34
Correct. A minor omission in the code will solve it - can you guess what that is without looking? :sly:
Obviously, the super magical... DynamicVariables=1! ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

I didn't look, honestly, is it:
[#Variable[&Measure1:]] or [#Variable[&Measure[#Num]:]]

EDIT: Damn! :rofl:
57686174 77696C6C 6265 77696C6C 6265
User avatar
balala
Rainmeter Sage
Posts: 16549
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Nested Conditions + Formulas

Post by balala »

sl23 wrote: July 21st, 2024, 9:11 pm My only issue is why the meter text displays:
Variable1: 12
Variable2: [#Variable0] or [#Variable0]

Although I can follow it, the first line is correct, but shouldn't the second line display:
Variable2: 34 or 34

I get the first display which doesn't resolve the variables of the second line.
Yes, indeed, you are right. This is a copy / paste problem on my side: I mistakenly didn't paste the needed DynamicVariables=1 option to the [MeterString] meter. Just add it and you'll get it properly working, showing 34 in both cases, as you figured out.
Sorry, my bad (as many times).
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Haha, no worries balala, it is an excellent example and I've added your post to it and will keep it as a reference! :thumbup:
57686174 77696C6C 6265 77696C6C 6265