It is currently October 24th, 2018, 1:59 am

How to change the value of one variable to another

General topics related to Rainmeter.
mixer
Posts: 2
Joined: September 18th, 2018, 6:09 am

How to change the value of one variable to another

mixer » September 18th, 2018, 6:17 am

I need to change the two colors in the variables by the click, but that does not work.
Please see the last line.
Thanks

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=30,30,30,100

[Variables]
width = 95
text = "my shop"
fontcolor = 205,205,205,155
online = 205,205,205,155
offline = 255,255,255,255
green = 0,255,0,255
red = 255,0,0,255

[MeasurePing1]
Measure=Plugin
Plugin=PingPlugin
DestAddress=172.16.0.1
UpdateRate=10
Timeout=2000
TimeoutValue=999
IfCondition=MeasurePing1=999
IfTrueAction=[!SetVariable text "my shop: offline"][!SetVariable fontcolor "#offline#"][!Redraw]
IfFalseAction=[!SetVariable text "my shop: ok"][!SetVariable fontcolor "#online#"][!Redraw]

[MeterPing1]
Meter=String
MeasureName=MeasurePing1
X=5
Y=5
W=#width#
H=20
FontFace=Myriad Pro Cond
FontSize=10
AntiAlias=1
StringEffect=Shadow
FontEffectColor=10,10,10,100
Text=#text#
FontColor=#fontcolor#
DynamicVariables=1
LeftMouseDownAction=[!SetVariable offline "#red#"][!SetVariable online "#green#"][!Redraw]
User avatar
balala
Rainmeter Sage
Posts: 6878
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to change the value of one variable to another

balala » September 18th, 2018, 7:46 am

mixer wrote:I need to change the two colors in the variables by the click, but that does not work.
Please see the last line.
It does work for me. One single detail is missing: you should have to add a DynamicVariables=1 option to the [MeasurePing1] measure, because in the IfTrueAction and IfFalseAction you've used the offlien and online variables, which are dynamically set through the !SetVariable bangs of the LeftMouseDownAction option of the [MeterPing1] meter. A such operation requires to set the dynamic variables on the measure(s) / meter(s) where you want to use the new value of the variable.

On the other hand there is not very clear (at least for me) what would you like to do. When loaded, the !SetVariable bangs of the IfTrueAction / IfFalsAction options set the fontcolor variable either to offline, or to online. When you click, the new colors are assigned to the offline and online variables. The fontcolor variable should have to change accordingly? If so, add an IfConditionMode=1 option to the [MeasurePing1] measure, to execute the appropriate bangs on each update of the measure. Otherwise once any option executed, if the value of the measure doesn't change, it isn't re-executed.

And one more tip: don't use the LeftMouseDownAction unless it is necessary for some reason. LeftMouseUpAction is better. Here you can find why.
mixer
Posts: 2
Joined: September 18th, 2018, 6:09 am

Re: How to change the value of one variable to another

mixer » September 18th, 2018, 10:51 pm

IfConditionMode=1 exactly what is needed. Thank you!
User avatar
balala
Rainmeter Sage
Posts: 6878
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to change the value of one variable to another

balala » September 19th, 2018, 12:27 pm

mixer wrote:IfConditionMode=1 exactly what is needed.
The DynamicVariables=1 option is same way needed. Probably you've added that one, too, if it's working well.