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, 63 / 4 in long division is equal to 15 with a remainder of 3. (15 * 4 = 60 and 63 - 60 = 3) So 63 % 4 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 [MeasureValue] / HighestValue.
When the skin is loaded or refreshed, the initial value of the measure will be 0.
[MeasureCounter]
Measure=Calc
Formula=(MeasureCounter % 10) + 1
The result on the first update is 0 / 10 which is equal to 0 with a remainder of 0. We add + 1 to that, and get 1.
On the second update, it is now 1 / 10 which is still 0, with a remainder of 1. We add + 1 to that, and it's now 2.
On the third update, it is now 2 / 10 which is still 0, with a remainder of 2. We add + 1 to that, and it's now 3.
....
On the tenth update, it is now 9 / 10 which is still 0, with a remainder of 9. We add + 1 to that, and it's now 10. The highest number we want to use.
On the next update, we are at 10, so we have 10 / 10, which is 1 with a remainder of 0, so we have "started over", and when we add + 1 to that we are back to 1.
It will just repeat that way, counting from 1 to whatever is after the % operator, forever.
An example
Let's assume we have 10 images, named MyImage1.png ... MyImage10.png in a folder called Images\ in our @Resources\ folder for our skin.
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 information
More details about how to use counters in Rainmeter can be found at Counters Guide.