It is currently March 28th, 2024, 7:52 pm

Something weird about the Random function

General topics related to Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Something weird about the Random function

Post by balala »

I just noticed today a weird fact related to the Random function, usable within the Calc measures.
A such Random function isn't updated on every update cycle, unless the UpdateRandom option is set to 1. The default value of this option being 0, if no a such option is set, we don't get the function updated regularly.
However if I set the dynamic variables on the measure which uses the Random function, it gets updated on every update cycle, even if the UpdateRandom is set to 0 (or is missing).
So, both of the following measures gets updated on each update cycle:

Code: Select all

[MeasureRandom]
Measure=Calc
Formula=Random
DynamicVariables=1

Code: Select all

[MeasureRandom]
Measure=Calc
Formula=Random
UpdateRandom=1
This seems weird to me. I mean that if I set the dynamic variables on the measure, even if based on the value of the UpdateRandom option, the function shouldn't have to get updated, it is.
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Something weird about the Random function

Post by Brian »

While I am not sure of the intent of the UpdateRandom option, I do believe it has to do with updating *just* the Random function and not updating any other "dynamic" value(s).

For example: Formula=#DynamicVar# + Random
And let's say that somewhere else in the code #DynamicVar# changes.

DynamicVariables=1 on this measure will result in retrieving the DynamicVar variable and adding it to a new Random number.

UpdateRandom=1 (with DynamicVariables=0) will result in using the same original DynamicVar variable and adding it to a new Random number.

So basically, DynamicVariables=1 will update each and every option in the measure including getting a new random number for Random function. Meanwhile, UpdateRandom=1 will only get a new random number for the Random function. DynamicVariables will override any setting for UpdateRandom.

I hope that makes sense.

-Brian
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Something weird about the Random function

Post by balala »

Brian wrote: August 8th, 2019, 8:55 pm I hope that makes sense.
Yes, right, it makes and this is clear. What seemed weird to me and I didn't expect this, is that setting on the dynamic variables and keeping the UpdateRandom on 0, will get updated the Random function. My thought was that if UpdateRandom is 0, the Random function is never updated, no matter if the dynamic variables are either set or not.