[FEATURE REQUEST - Important] !UpdateVariables bang
Posted: August 22nd, 2020, 10:40 am
This very annoying problem has been mentioned before (see here, and probably in a bunch of other places as well), so I'm not the only one affected - it's about the update of variables. See the code below, which no matter how you look at it, should in theory update (or modify, change, whatever) the String2 and String3 variables once String1 is changed, since it's a dependency chain between them:
Neither of the mouse actions achieve what would be logical to happen, i.e. the variables internally becoming either
or
on left mouse click.
Apart from that, there is also the related problem of variables not updating within the option their change was made, so this leads to downright wrong and inconsistent behavior, not to mention requiring the user or skin designer to write a TON of !SetVariable bangs using hardcoded values (or even worse, having a TON of .inc files to handle that, or a TON of measures acting as "fake variables" because the damn variables just can't be actual variables like they're supposed to be) just to update dependent variables - and this becomes even worse if the number of variables increase.
That being said, I know and understand why this happens: the [Variables] section is not dynamic, thus can't do this automatically. You can't modify that without breaking backwards compatibilty, I get that. What I propose though is a simple !UpdateVariables bang that "updates" the value of variables manually at the time of calling, pretty much the way !UpdateMeasure does. I'm not sure this is possible directly or it needs some "coding hacks" to get it done, but for sure it would be tremendously useful. Basically do what !Refresh does but with the current values of the variables and without upating measures/meters/etc.
Hopefully my case for such an addition (or other workable solution) to Rainmeter is strong enough to warrant at least some thinking about it without the usual "it can't be done" prejudice. Now if that would be put in practice as well that would be really awesome, but I'm getting ahead of myself here with this wishful thinking...
Code: Select all
[Variables]
String1="string"
String2="A #String1# is made out of characters"
String3="#String2# and it has a length."
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[MeasureToggler]
Measure=Calc
Formula=(1-MeasureToggler)
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^0$":"string","^1$":"text"
DynamicVariables=1
---Meters---
[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="String1 Format = either 'string' or 'text' (click based, dynamic)#CRLF#String2 Format = 'A #*String1*# is made out of characters'#CRLF#String3 Format = '#*String2*# and it has a length.'#CRLF##CRLF#String1 = #String1##CRLF#String2 = #String2##CRLF#String3 = #String3#"
LeftMouseUpAction=[!UpdateMeasure *][!SetVariable String1 "[MeasureToggler]"][!UpdateMeter *][!Redraw]
;LeftMouseUpAction=[!UpdateMeasure *][!SetVariable String1 "[MeasureToggler]"][!UpdateMeter *][!Redraw][!SetVariable String2 "A #String1# is made out of characters"][!UpdateMeter *][!Redraw][!SetVariable String3 "#String2# and it has a length."][!UpdateMeter *][!Redraw]
;LeftMouseUpAction=[!UpdateMeasure *][!WriteKeyValue Variables String1 "[MeasureToggler]"][!Refresh]
DynamicVariables=1
Code: Select all
String1="text"
String2="A text is made out of characters"
String3="A text is made out of characters and it has a length."
Code: Select all
String1="string"
String2="A string is made out of characters"
String3="A string is made out of characters and it has a length."
Apart from that, there is also the related problem of variables not updating within the option their change was made, so this leads to downright wrong and inconsistent behavior, not to mention requiring the user or skin designer to write a TON of !SetVariable bangs using hardcoded values (or even worse, having a TON of .inc files to handle that, or a TON of measures acting as "fake variables" because the damn variables just can't be actual variables like they're supposed to be) just to update dependent variables - and this becomes even worse if the number of variables increase.
That being said, I know and understand why this happens: the [Variables] section is not dynamic, thus can't do this automatically. You can't modify that without breaking backwards compatibilty, I get that. What I propose though is a simple !UpdateVariables bang that "updates" the value of variables manually at the time of calling, pretty much the way !UpdateMeasure does. I'm not sure this is possible directly or it needs some "coding hacks" to get it done, but for sure it would be tremendously useful. Basically do what !Refresh does but with the current values of the variables and without upating measures/meters/etc.
Hopefully my case for such an addition (or other workable solution) to Rainmeter is strong enough to warrant at least some thinking about it without the usual "it can't be done" prejudice. Now if that would be put in practice as well that would be really awesome, but I'm getting ahead of myself here with this wishful thinking...