Nesting Variables


There may be times when you want to embed or 'nest' variables within variables. This might include any combination of #Variables#, #Built-InVariables#, [SectionVariables] or $MouseVariables$.

So for instance, the goal might be to have things like:

Text=#MyVar#MyOtherVar##
Text=#MyVar[MyMeasure]#
Text=[MyMeasure#MyVar#]
Text=[MyMeasure[MyOtherMeasure]]

This creates ambiguities that simply can't be reliably parsed and understood by Rainmeter, and can't work.

Rainmeter solves this by having an alternative form of these variables. These function exactly as their normal counterparts do, but can successfully be nested.

The alternative 'nesting' form of the variables

[#VarName]   Replaces: #VarName#
[&MeasureName]   Replaces: [MeasureName]
[$MouseVar]   Replaces: $MouseVar$


So our examples above would look like:

Text=[#MyVar[#MyOtherVar]]
Text=[#MyVar[&MyMeasure]]
Text=[&MyMeasure[#MyVar]]
Text=[&MyMeasure[&MyOtherMeasure]]

Notes:

Unless you are in fact 'nesting' variables within variables, there is no other benefit to using these instead of the normal syntax. It is not suggested that this in any way 'deprecates' the current style of using variables in your skin. This is an 'alternative' way, that simply allows for nesting to be successful. Use them all the time, or use them just when needed, that is a matter of personal preference.

Do note however, that any use of Inline Lua in measures or meters will always require that this Nesting Variables syntax be used, as by its nature as a [SectionVariable], Inline Lua will generally require nesting of other variables or section variables in the parameters.

All the same rules for when DynamicVaribles=1 is required where these are used still apply. Consider each component of the nested variable. If any of them require dynamic variables to successfully get the current value, then it must be used. In general, ANY nested variable that contains [&MeasureName] is likely to require DynamicVaribles=1 when used in measures or meters.

If you are escaping a variable and need to use the nested form, the syntax is:

[#*VarName*]
[&*MeasureName*]

Examples

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
Var1=One
Var2=Two

[MeasureStringOne]
Measure=String
String="I'm the first Measure"

[MeasureStringTwo]
Measure=String
String="I'm the second Measure"

[MeterTest1]
Meter=String
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[&MeasureString[#Var1]]#CRLF#[&MeasureString[#Var2]]
DynamicVariables=1

[MeasureNum3]
Measure=Calc
Formula=3

[MeasureNum4]
Measure=Calc
Formula=4

[MeasureString3]
Measure=String
String="I'm the third Measure"

[MeasureString4]
Measure=String
String="I'm the fourth Measure"

[MeterTest2]
Meter=String
Y=10R
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[&MeasureString[&MeasureNum3]]#CRLF#[&MeasureString[&MeasureNum4]]
DynamicVariables=1
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=5
UpdateRandom=1
UniqueRandom=1

[Measure1]
Measure=String
String="I'm One"

[Measure2]
Measure=String
String="I'm Two"

[Measure3]
Measure=String
String="I'm Three"

[Measure4]
Measure=String
String="I'm Four"

[Measure5]
Measure=String
String="I'm Five"

[MeterTest1]
Meter=String
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[&Measure[&MeasureRandom]]
DynamicVariables=1
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
XPos1=15
XPos2=10
XPos3=30
XPos4=100
XPos5=0

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=5
UpdateRandom=1
UniqueRandom=1

[MeterTest1]
Meter=String
X=[#XPos[&MeasureRandom]]
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Hello World
DynamicVariables=1

Download Examples

You can download the above examples as a .rmskin.