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

Nested Conditions + Formulas

Get help with creating, editing & fixing problems with skins
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 »

How do I use a #CURRENTSECTION# variable with this: [m1Stat:]?

Code: Select all

[1Stat]
Meter=Shape
MeterStyle=sBar2
Shape=Rectangle 0, 0, ([#[#CURRENTSECTION]]=1?0:#BarW#), -#BarH# | StrokeWidth 0 | Fill Color #White40#
Shape2=Rectangle 0, 0, ([#[#CURRENTSECTION]]=1?0:#BarW#+2), ([m1Stat:]/100*(-#BarH#)) | StrokeWidth 0 | Fill Color [#C[#CURRENTSECTION]],#BarAlphe#
Shape3=Rectangle 0, ([#[#CURRENTSECTION]]=1?0:(([m1Stat:]/100*(-#BarH#)))), (#1Stat#=1?0:#BarW#), 2 | StrokeWidth 0 | Fill Color [#C[#CURRENTSECTION]]
ToolTipText=CPU: [m1Stat:]%
X=0
Currently, [#[#CURRENTSECTION]] is pointing to a variable called 1Stat, which works fine, but I'm trying to replace the [m1Stat] with [#m[#CURRENTSECTION]], which fails, could you tell me what I'm doing wrong here please, thank you. :) :thumbup:
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 20th, 2024, 8:52 pm Currently, [#[#CURRENTSECTION]] is pointing to a variable called 1Stat, which works fine, but I'm trying to replace the [m1Stat] with [#m[#CURRENTSECTION]], which fails, could you tell me what I'm doing wrong here please, thank you. :) :thumbup:
I assume [m1Stat] is a measure, right? If it is, try this: [&m[#CURRENTSECTION]].
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 »

Sorry, yes it's a measure.
Unfortunately, that's a no go! :(

Everything stopped working for every shape meter I added that too.
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 20th, 2024, 5:06 pm I seem unable to get it working the other way: [#[#CURRENTSECTION]CPU]. This won't work and I have no idea how to make it work. Could you help please :thumbup:

Current Section = m1
Variable = m1CPU
[#[&[#CURRENTSECTION]]CPU]
or, if you need only the CURRENTSECTION name, instead of that section's value:
[#[#CURRENTSECTION]CPU]
sl23 wrote: July 20th, 2024, 8:52 pm How do I use a #CURRENTSECTION# variable with this: [m1Stat:]?
[...]
Currently, [#[#CURRENTSECTION]] is pointing to a variable called 1Stat, which works fine, but I'm trying to replace the [m1Stat] with [#m[#CURRENTSECTION]], which fails, could you tell me what I'm doing wrong here please, thank you. :) :thumbup:
[&m[&[#CURRENTSECTION]]:]
or, if you need only the CURRENTSECTION name, instead of that section's value:
[&m[#CURRENTSECTION]:]

The manual is sufficient for such cases, it's just that you have to pay attention to whether it's a section (&) or a variable (#) prefix that you need, and also if you need the name itself (the string) or the value of the element with that name (especially if that element is a measure). Plus, in your case, don't forget the : if by any chance your measure has different string and number values and you need the latter one.

In case it's not obvious, DynamicVariables=1 is needed for these things to work.
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 »

Yeah, true, it probably is sufficient if you know what you're doing! lol

See, it's just confused me now, why do you have to use the & for a Section, but #CURRENTSECTION# doesn't require it?
With programming, nothing seems to be consistent, everything depends on where you use it as to how it is used, and that is the whole problem here.

Thanks for trying to explain, I just don't get it because of that lack of fundamental knowledge so I don't see how it all fits together. I would like to, I've tried to, but I just don't have the will, energy, or motivation to keep at it now. It's a bugger getting old! :rofl:

Taking a look at those nested variables, it just makes me wonder, how the hell do you work it out? There's no logic to it from where I stand. If I think about how they work, it just seems logical the way I originally did it. Is there any where to learn how these work, as I am never going to be able to do this on my own until I gain that understanding.

From what you're saying, if you use a measure name as a section variable you should use &, but if it's a variable you use #? Or is that only when Nested? I could go on and on with the questions, but I guess you're already fed up answering them all! :lol:

Why the &? Why not all the time? Why does it require sometimes additional square brackets but not others. This is why I say the manual is lacking. It's not a criticism, just an observation, and a little frustration! Sorry bout that! lol :oops:

Sorry if I've been a bit full on, I'm trying to learn this stuff and I really do appreciate your help and time. I'm going to get these skins done and that'll be me done for quite a while I expect so you'll have a nice long break from me! :D :lol:

Thanks. :thumbup:
Last edited by sl23 on July 22nd, 2024, 10:23 pm, edited 1 time in total.
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 »

This is what I mean: Hidden=([#[#CURRENTSECTION[#Stat]]:]=1 ? 1 : 0)
If I can't learn how these things work, I have to keep asking for help and it gets a bit much for you and for me to have to keep asking.

Could someone please explain how these work, I know it's in the manual, but that isn't enough to understand the fundamental workings. Maybe I'm wrong and just don't see it due to my perspective. But it would be nice if someone could join the dots please, cos I just don't get it. :(

Sorry if I come across the wrong way, I can't help it due to personal issues, it really isn't focused on anyone here or anything to do with the app or manual or anything. :rosegift:

EDIT: Oops, forgot to mention the Variables I'm trying to resolve!
the section is [1]
the variable is #1Stat#
So I'm trying to add the Stat part to the 1 and get the number value which is either 1 or 0.
eg: 1Stat=0
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, 4:14 pm See, it's just confused me now, why do you have to use the & for a Section, but #CURRENTSECTION# doesn't require it?
sl23 wrote: July 21st, 2024, 4:14 pm Why the &? Why not all the time? Why do it require sometimes additional square brackets but not others.
On the original syntax, introduced probably by the first version of Rainmeter, these are the ways you're refering to variables and measures:
  • [Measure] - in fact by this you get the string value of the measure. In many (most?) cases this my be identical with its numeric value, however there are some exceptions.
  • #Variable#
This approach has a huge problem: you can't embed a variable into another, for instance. So if you have the following variables:

Code: Select all

[Variables]
Variable1=12
Variable2=34
Num=1
In this case #Variable#Num## makes no sense, Rainmeter doesn't deal with this. But since we have the nesting variables, the [#Variable[#Num]] makes sense and is resolved by Rainmeter, which returns 12 in this case.
This is the nesting syntax. In this one you're referring to variables and measure by the followings:
  • [&Measure]
  • [#Variable]
Even if this approach has been introduced, the old syntax has to be kept, due to the backward compatibility. This is why it still works, but the new syntax is working as well. So now there are two different ways to work with these lements. It's completely up to the user which one he wants to use, when both are valid and can be used. So there is nothing which tells to use the #Variable# or the [#Variable] syntax to get the variable. Both are valid and can be used. Same way can you use either the #CURRENTSECTION# or the [#CURRENTSECTION] syntax, to get the name of the section.
sl23 wrote: July 21st, 2024, 4:14 pm The manual is good, but as I said before, it's written from the perspective of you knowing the fundamentals.
sl23 wrote: July 21st, 2024, 4:14 pm This is why I say the manual is lacking.
Unfortunately (or fortunately?) there is no way the manual to can cover all cases. You as a user have to read it and try to understand. And you have a very good tool to can decide in cases when you don't know what to do: the try-out method. Write a small code, dissect it, alter it until you finally figure out how to achieve what you want to achieve. We all do this from time to time (me at least definitely do, but I don't think there is any user, including the developers, who could know the solution to any question all the time, without trying out).
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 »

Hey, thanks balala, that has helped a little. I do realise the manual isn't a "Teach me programming" guide, and it really can't be. It's just so frustrating wanting to do something and not knowing how to, why it doesn't work, unable to find answers, keep asking for help, etc, I am very independent and dislike keep asking for help. But thanks for explaining.

So really I should use [#CURRENTSECTION] instead of #CURRENTSECTION#?
If I refer to a Measure in a Variable, I should use [&MeasureName] and not [MeasureName]?
If I stick to that, then it will help to gain understanding how to combine them, I think. That's where the confusion was coming from, I tried reading the Nested Variables in the manual, but it's not clear to me how or why the & was used. If I don't use & and instead use #, then that's why I'm running into trouble I suppose?

A [MeasureName] is that considered a Variable too? I mean if used as a reference such as X=[MeasureName:]
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 »

So going by my above example, this is how I see it, but it doesn't work for me: Hidden=([#CURRENTSECTION[#Stat]]=1 ? 0 : 1)
Just to reiterate:
the section is [1]
the variable is #1Stat#
So I'm trying to add the Stat part to the 1 and get the number value which is either 1 or 0.
eg: 1Stat=0
The starting point is then #CURRENTSECTION# which you're saying I should use [#CURRENTSECTION].
Then I need to add 'Stat' to it and the whole thing needs to be a one word variable. That to me looks, as above, like this: [#CURRENTSECTION[#Stat]].

So what exactly is the cause of error here?
Thanks for your help. :)
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, 4:14 pmSee, it's just confused me now, why do you have to use the & for a Section, but #CURRENTSECTION# doesn't require it?
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.
sl23 wrote: July 21st, 2024, 4:14 pmTaking a look at those nested variables, it just makes me wonder, how the hell do you work it out? There's no logic to it from where I stand.
[...]
From what you're saying, if you use a measure name as a section variable you should use &, but if it's a variable you use #? Or is that only when Nested?
[...]
Why the &? Why not all the time? Why do it require sometimes additional square brackets but not others. This is why I say the manual is lacking
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.
sl23 wrote: July 21st, 2024, 7:42 pm This is what I mean: Hidden=([#[#CURRENTSECTION[#Stat]]:]=1 ? 1 : 0)
[...]
EDIT: Oops, forgot to mention the Variables I'm trying to resolve!
the section is [1]
the variable is #1Stat#
So I'm trying to add the Stat part to the 1 and get the number value which is either 1 or 0.
eg: 1Stat=0
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
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth