This is useful in any number of circumstances, like displaying a series of images, delaying some action for some number of skin updates, anything where you want to say "create a loop from 1 to XX".
In Rainmeter, this is done by using a mathematical formula, normally but not exclusively in a Calc measure. The formula will use the modulo mathematical operator.
Modulus math can be complicated in its explanation, as it used different ways in different contexts, but in the sense that we use it in a counter in Rainmeter, it is really pretty simple.
The % modulo mathematical operator in Rainmeter simply means "the remainder" when two numbers are divided. For instance, in long division is equal to 15 with a remainder of 3. (15 * 4 = 60 and 63 - 60 = 3) So is equal to 3.
A counter in Rainmeter
To use it as a counter, we use the current value of the measure as the dividend, and the highest number we want to count to as the divisor. So it is .
When the skin is loaded or refreshed, the initial value of the measure will be 0.
Formula=(MeasureCounter % 10) + 1
The result on the first update is which is equal to 0 with a remainder of 0. We add to that, and get .
On the second update, it is now which is still 0, with a remainder of 1. We add to that, and it's now .
On the third update, it is now which is still 0, with a remainder of 2. We add to that, and it's now .
On the tenth update, it is now which is still 0, with a remainder of 9. We add to that, and it's now . The highest number we want to use.
On the next update, we are at , so we have , which is 1 with a remainder of 0, so we have "started over", and when we add to that we are back to .
It will just repeat that way, counting from 1 to whatever is after the % operator, forever.
Let's assume we have 10 images, named MyImage1.png ... MyImage10.png in a folder called Images\ in our @Resources\ folder for our skin.
That will display the images, starting with MyImage1.png through MyImage10.png. It will then start over, and continue in that way.
Code: Select all
[Rainmeter] Update=1000 [Variables] SecondsBetween=30 [MeasureCounter] Measure=Calc Formula=(MeasureCounter % 10) + 1 UpdateDivider=#SecondsBetween# [MeterImage] Meter=Image ImagePath=#@#Images\ ImageName=MyImage[MeasureCounter].png DynamicVariables=1
You can control the speed of the change by simply setting UpdateDivider=XX (where XX is the number of seconds between changes, assuming that the setting of Update in [Rainmeter] is 1000).
More details about how to use counters in Rainmeter can be found at Counters Guide.