[Feature Suggestion] Current Section Index
Posted: May 1st, 2020, 10:07 pm
Note: Extracting a current section's index (or of any - altered or not - index occurence of any section, for that matter) is possible now by using a Rainmeter version greater than 4.4.0.3493 (due to the fix mentioned here) and a Lua function similar to the one in the skin here. Therefore, the issues to which this thread refers to are now more or less obsolete.
In Rainmeter, one can get the name of the section in which the variable is used with the help of the #CURRENTSECTION# built-in section variable. This is helpful, among other things, to copy paste the same (repetitive) code to different sections without bothering to change the section name on each use. How about a more specific built-in section variable called, say, #CURRENTSECTIONINDEX#, which would return the trailing number at the end of a current section name (or, if the Rainmeter developers are nice enough, return either the first or the last number in a current section name)?
For the trailing number implementation, it would make this:
into this (#CURRENTSECTIONINDEX#=13):
For the first number implementation, it would make this:
into this (#CURRENTSECTIONINDEX#=12):
For the last number implementation, it would make this:
into this (#CURRENTSECTIONINDEX#=13):
Of course, which implementation would be chosen is up to the developers (if interested, that is). Personally, I would lean towards the 'last number' one, since it doesn't always make sense to place the number at the very end of the section name as it can be in the middle of it, and placing it towards the start of that name is rarely used.
P.S. Obviously, it would be great if the #CURRENTSECTIONINDEX# variable could be used as a numerical value as well, apart from using it as a string value, so that it would be suited for both an IfCondition and an IfMatch attached to the section, but I'm not sure this is possible - I'm just speculating...
In Rainmeter, one can get the name of the section in which the variable is used with the help of the #CURRENTSECTION# built-in section variable. This is helpful, among other things, to copy paste the same (repetitive) code to different sections without bothering to change the section name on each use. How about a more specific built-in section variable called, say, #CURRENTSECTIONINDEX#, which would return the trailing number at the end of a current section name (or, if the Rainmeter developers are nice enough, return either the first or the last number in a current section name)?
For the trailing number implementation, it would make this:
Code: Select all
[MeasureCPUUsage13]
Measure=CPU
Processor=13
Code: Select all
[MeasureCPUUsage13]
Measure=CPU
Processor=#CURRENTSECTIONINDEX#
For the first number implementation, it would make this:
Code: Select all
[Measure12CPU13Usage]
Measure=CPU
Processor=12
Code: Select all
[Measure12CPU13Usage]
Measure=CPU
Processor=#CURRENTSECTIONINDEX#
For the last number implementation, it would make this:
Code: Select all
[Measure12CPU13Usage]
Measure=CPU
Processor=13
Code: Select all
[Measure12CPU13Usage]
Measure=CPU
Processor=#CURRENTSECTIONINDEX#
Of course, which implementation would be chosen is up to the developers (if interested, that is). Personally, I would lean towards the 'last number' one, since it doesn't always make sense to place the number at the very end of the section name as it can be in the middle of it, and placing it towards the start of that name is rarely used.
P.S. Obviously, it would be great if the #CURRENTSECTIONINDEX# variable could be used as a numerical value as well, apart from using it as a string value, so that it would be suited for both an IfCondition and an IfMatch attached to the section, but I'm not sure this is possible - I'm just speculating...