It is currently March 28th, 2024, 11:39 pm

IfCondition update clarification

Get help with creating, editing & fixing problems with skins
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

IfCondition update clarification

Post by rbriddickk84 »

Greetings!

I would like to clarify a question about IfCondition's update effect.
I try to fix my EasyRGBpick skin, where i simply want to measure and set variables at every mouse click.

Here is the main code:

Code: Select all


[Rainmeter]
Update=1000
AccurateText=1

[Variables]
fx=0
fTy=0
fy=0

mzpozX=#mzpozTx#
mzpozY=#mzpozTy#

U=[!UpdateMeasureGroup "cls"][!UpdateMeterGroup "ims"][!Redraw]

[detectingArea]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=#alx#
H=#aly#
LeftMouseDownAction=[!SetVariable mzpozX $MouseX$][!SetVariable mzpozY $MouseY$][!SetVariable fx $MouseX:%$][!SetVariable fTy $MouseY:%$]#U#
DynamicVariables=1

[--------------------- Calculations 1 -----------------------------]

[BaseRed]
Measure=Calc
Group=cls
Formula=#fx#
IfCondition=#fx# < 16
IfTrueAction=[!SetVariable rtx 255]
IfCondition2=(#fx# > 15) && (#fx# < 33)
IfTrueAction2=[!SetVariable rtx (16-(#fx#-16))]
DynamicVariables=1
UpdateDivider=-1

So in the "BaseRed" measure, the "IfCondition2" is updating once. I mean no matter how many times i click, and the condition is true, the "rtx" value remains the same as the first time was true. So it's acting like "The condition2 is true, i run the TrueAction2, and i ignore the other times, when the Condition2 is true".

I don't know if i write it clearly, it's strange. I just want to know that if the Measure updates, the IfCondition2 is running only once, if it's True, or every time when it's True?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IfCondition update clarification

Post by eclectic-tech »

Manual [url=https://docs.rainmeter.net/manual-beta/measures/general-options/ifconditions/#IfTrueAction]@IfTrueAction[/url] wrote:The action is executed only once when the condition becomes "true", so it needs to become "false" and again "true" to execute again.
You might get it to work the way you want, by adding IfConditionMode=1 to force it to evaluate on every update.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: IfCondition update clarification

Post by rbriddickk84 »

eclectic-tech wrote:You might get it to work the way you want, by adding IfConditionMode=1 to force it to evaluate on every update.
Million thanks! I think i should read over all the manuals again to see what's new in it. Usually i read all the update release notes, but probably i missed this. :)

Thank you again! :D
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IfCondition update clarification

Post by eclectic-tech »

Not a problem... I'm always referring back to the manual... How quickly we can forget things is scary! :D
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: IfCondition update clarification

Post by balala »

eclectic-tech wrote:You might get it to work the way you want, by adding IfConditionMode=1 to force it to evaluate on every update.
Just for a quick clarification rbriddickk84, the IfConditionMode=1 option is needed, because if an IfCondition is true, without the IfConditionMode set, the appropriate IfTrueAction will be executed only once, when the condition is met. A new execution will occurs ONLY if the condition become false, then true again. If you add the IfConditionMode=1 option to the measure, on each update of the measure (no matter if in the meantime the condition was or wasn't met) the appropriate IfTrueAction will be executed, if the condition is met.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition update clarification

Post by jsmorley »

Just be careful in your design that you use IfConditionMode=1 appropriately. The point of why these "IF" actions work the way they do it to prevent your measure from hammering the skin with actions or changes or forced updates when a value becomes "true" and just stays "true". It is both pointless and potentially a performance issue to keep changing "A" to "A" once a second, if you see what I mean.

IfConditionMode=1 has its uses, but some thought should always be given. I always look at a need for IfConditionMode=1 as an automatic trigger to say "I wonder if I could do this another way that doesn't require it?"
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: IfCondition update clarification

Post by rbriddickk84 »

Yeah, i learned from the manual. Thanks again, for both of you! :D
Yeah, i am getting old, trying to figure out things without simply reading the basic manual! :D

And yes jsmorley, i hope UpdateDivider=-1 handle the stress in my case, it's really needed to be updated the condition here, but only when the measure is updated. ;)
Thank you for warning me! :D

I always optimize my skins to only update things, when it's really needed to be updated, so costs the very minimum resources as possible! :)
Last edited by rbriddickk84 on June 3rd, 2017, 12:48 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition update clarification

Post by jsmorley »

rbriddickk84 wrote:Yeah, i learned from the manual. Thanks again, for both of you! :D
Yeah, i am getting old, trying to figure out things without simply reading the basic manual! :D

And yes jsmorley, i hope UpdateDivider=-1 handle the stress in my case, it's really needed to be updated the condition here, but only when the measure is updated. ;)
Thank you for warning me! :D
Yes, IfConditionMode=1 in conjunction with UpdateDivider=-1 is the perfect solution when the changes are driven by mouse actions.