It is currently October 19th, 2021, 1:46 am

Question on DynamicVariables=1

Help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 13324
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Question on DynamicVariables=1

Post by balala »

mmxiv wrote: April 8th, 2021, 4:05 pm #1: In case 1 of the measure1, will the measure2 and meter1 be updated in every case, true and false?
Yep, they will be, as long as the value returned by the [measure1] measure changes. This update goes on due to the OnchangeAction option of the [measure1] measure, not due to the IfTrueAction and IfFalseAction options. These options are executed each only once when the measure becomes equal to 0 (IfFalseAction) or goes above 0 (IfTrueAction). To execute once again any of these options, the measure should go to false (if it's true) or vice-versa. You can force the options to execute on each update cycle of the skin, adding an IfConditionMode=1 option to the measure, but take care: this might be a "big gun" and easily can lead to an infinte cycle, so it has to be treated carefully.
mmxiv wrote: April 8th, 2021, 4:05 pm #2: In case 2, will the measure2 and meter1 be updated every 1 sec and will the same happen in every of the scenarios, true and false?
Not exactly, because as said above, once IfTrueAction (or IfFalseAction) executed, it is executed once again ONLY if the condition becomes false (if has been true), or true (if has been false), then comes back to true / false again. In this case the appropriate option is executed only once, then the condition has to change in order to get one of those options executed once again. If you pay atention, you'll see that with this code the skin shows 0, then a greater value, then the next value is again 0 and so on, exactly due to what I described above.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

mmxiv wrote: April 8th, 2021, 4:05 pmHello! I have 2 questions if someone could give the right answer...
Both these questions have easy answers, that you can see for yourself, with a little bit of looping and logging kung-fu :sly: :

Code: Select all

[Variables]
Start=-5
End=5
Incr=1

[Rainmeter]
Update=1000

---Measures---

[MeasureLoop]
Measure=Loop
StartValue=#Start#
EndValue=#End#
Increment=#Incr#
LoopCount=1

[MeasurePingPong]
Measure=Calc
IfCondition=MeasureLoop = #End#
IfTrueAction=[!SetOption MeasureLoop InvertMeasure 1][!UpdateMeasure MeasureLoop]
IfCondition2=MeasureLoop = #Start#
IfTrueAction2=[!SetOption MeasureLoop InvertMeasure 0][!UpdateMeasure MeasureLoop]

[measure1]
Measure=Calc
Formula=MeasureLoop
IfCondition=(#CURRENTSECTION# > 0)
IfTrueAction=[!EnableMeasure "measure2"]
IfFalseAction=[!DisableMeasure "measure2"]
OnChangeAction=[!UpdateMeasure "measure2"][!UpdateMeter "meter1"]
DynamicVariables=1

[measure2]
Measure=Calc
Formula=measure1
Disabled=1
UpdateDivider=-1
OnUpdateAction=[!Log "measure2 was updated and its value is [measure1]"]
DynamicVariables=1

---Meters---

[meter1]
Meter=String
W=100
H=100
SolidColor=0,0,0,255
UpdateDivider=-1
OnUpdateAction=[!Log "meter1 was updated"]
This is for question 1, I'm sure you can replicate it for question 2. What I did is to pass a ping-pong loop (alternating from -5 to 5 and backwards) to the measure1 in order to not depend on random NetOut values that you can't control, and then add some logging in measure2 and meter1 to show when those updates actually happen. All you need to do is watch the Log and alternatively to have a look at the number/string values of the measures in your skin and/or what happens when they are disabled (i.e. greyed out):
Updates.jpg
Logs.jpg
As you can see, the measure2 updates don't always happen, but only when measure1>0; meter1 is always updated though, since it's enabled at all times and the OnChange event triggers whenever measure1 changes (but not when it's constant).
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

balala wrote: April 8th, 2021, 6:07 pmYep, they will be...
Not really, see my reply. The said measure is subject to the Disabled flag as well, not just to the OnChangeAction in the previous measure. ;-)
User avatar
balala
Rainmeter Sage
Posts: 13324
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Question on DynamicVariables=1

Post by balala »

Yincognito wrote: April 8th, 2021, 6:20 pm Not really, see my reply. The said measure is subject to the Disabled flag as well, not just to the OnChangeAction in the previous measure. ;-)
True, however note that even if [measure2] is disabled, it is enabled on the IfTrueAction option of [measure1] measure (in both codes the IfTrueAction option contains the [!EnableMeasure "measure2"] bang). This option is executed when [measure1] becomes gretaer then 0. When you load / refresh the skin, this measure is zero, then when it first time increases above 0, [measure2] gets enabled.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

balala wrote: April 8th, 2021, 6:38 pm True, however note that even if [measure2] is disabled, it is enabled on the IfTrueAction option of [measure1] measure (in both codes the IfTrueAction option contains the [!EnableMeasure "measure2"] bang). This option is executed when [measure1] becomes gretaer then 0. When you load / refresh the skin, this measure is zero, then when it first time increases above 0, [measure2] gets enabled.
Indeed, but the question was whether the update happens always (with respect to the True and False states). Sure, incidentally a NetOut value doesn't get below 0, but for a measure that can have negative or 0 values, the update of the said measure does not always happen, but only when the value of the triggering measure changes AND it's above 0.
Last edited by Yincognito on April 8th, 2021, 6:48 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 13324
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Question on DynamicVariables=1

Post by balala »

Yincognito wrote: April 8th, 2021, 6:45 pm Indeed, but the question was whether the update happens always (with respect to the True and False states). Sure, incidentally a NetOut value doesn't get below 0, but for a measure that can have negative values, the update of the said measure does not always happen, but only when the value of the triggering measure changes AND it's above 0.
Ok, don't argue. However my reply was related to the posted code, not to another code, with different kind of measure.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

balala wrote: April 8th, 2021, 6:48 pm Ok, don't argue. However my reply was related to the posted code, not to another code, with different kind of measure.
The posted code can (as you already mentioned) have 0 values for NetOut - case in which measure2 does not update, so the update doesn't always happen (the condition has to yield True for that, among other things). The fact that I illustrated the behavior using some minor additions like a loop or some logging doesn't make the behavior of code or the measures in question "different" in any way. Just saying... :confused:
User avatar
mmxiv
Posts: 17
Joined: February 14th, 2021, 5:48 pm

Re: Question on DynamicVariables=1

Post by mmxiv »

your partially different answers confused me a bit.
so, I'm looking for a solution that will update measure2 and meter1 ONLY ONCE either the condition is "0" or "> 0". So measure2 and meter1 MUST be updated whenever the condition changes, but only once in any case. And ofc, measure2 MUST be disabled when condition is 0 and enabled when higher.

This could look like an easy question, but as I experienced some issue, i had to come here for the clarifications.
I think that this solution works as I wish, but it makes a glitch of the meter on every !Refresh.

Code: Select all

[measure1]
Measure=NetOut
IfCondition=(#CURRENTSECTION# > 0)
IfTrueAction=[!EnableMeasure "measure2"]
IfFalseAction=[!UpdateMeasure "measure2"][!DisableMeasure "measure2"]
OnChangeAction=[!UpdateMeasure "measure2"][!UpdateMeter "meter1"]
DynamicVariables=1
The glitch disappears with IfTrueAction=[!EnableMeasure "measure2"][!UpdateMeasure "measure2"] set, but since Yincognito said that if condiotion is above 0, it will update measure2 every 1000ms, it is not acceptable solution. Or I misunderstood something here.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

mmxiv wrote: April 8th, 2021, 4:05 pmHello! I have 2 questions if someone could give the right answer...
To conclude, the right answer to both your literal questions is NO. When measure1 doesn't change or is 0 (1st question), or measure1 is 0 (2nd question), measure2 will not update. In other words, the True and False states yielded by the IfCondition do have an impact on the updates.
User avatar
Yincognito
Rainmeter Sage
Posts: 4069
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Question on DynamicVariables=1

Post by Yincognito »

mmxiv wrote: April 8th, 2021, 7:15 pmso, I'm looking for a solution that will update measure2 and meter1 ONLY ONCE either the condition is "0" or "> 0". So measure2 and meter1 MUST be updated whenever the condition changes, but only once in any case. And ofc, measure2 MUST be disabled when condition is 0 and enabled when higher.
That's what you should have said in the first place: what DO YOU WANT the code to do. Having said that, there's a logical contradiction in your request (not sure if it's the cause of the glitch, but it needs some clarification anyway): on one hand, you want measure2 to "update" even if condition is "0", on the other hand you want it "disabled" when condition is "0". Technically, you can do that, but you won't see some changes as a result, since the measure is disabled (it will basically "update the disabled state"). So... you understand where I'm going with this, right?