It is currently March 28th, 2024, 1:25 pm

Looping in Rainmeter (?)

Get help with creating, editing & fixing problems with skins
Post Reply
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Looping in Rainmeter (?)

Post by csm725 »

Is there such thing as a [do/whille, for] loop in Rainmeter?
From what I gather, there isn't...
If there is (and I've somehow missed it), how would I convert the following C#/Java/Rainmeter code to Rainmeter (just a template would help, not necessary to convert code to Rainmeter):
while (#pos#<18)
do LeftMouseUpAction=!RainmeterHideMeterGroup App#pos#
//so if pos = 1, hide group App1
//pos=2, hide grp App2
//etc etc etc
Logically, when 'pos' is less than 18, hide the group App#pos# (If pos = 1, hide App1; if pos = 2, hide App2, and so on and so forth).

Is there any way to code the above?
User avatar
kenz0
Developer
Posts: 263
Joined: July 31st, 2009, 2:23 pm
Location: Tokyo, JPN
Contact:

Re: Looping in Rainmeter (?)

Post by kenz0 »

In Rainmeter, this case is solved using Calc and IF statement.

[Condition]
Measure=Calc
Formula=#pos# < 18 ? 1 : 0
IfEqualValue=1
IfEqualAction=!RainmeterHideMeterGroup App#pos#

If #pos# is less than 18, [Condition] will return 1 then, the action will be executed by IfEqualAction.
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Looping in Rainmeter (?)

Post by csm725 »

Using HideMeterGroup App#pos# doesn't seem to work...
How could I round pos to 1 decimal place in Calc?
User avatar
kenz0
Developer
Posts: 263
Joined: July 31st, 2009, 2:23 pm
Location: Tokyo, JPN
Contact:

Re: Looping in Rainmeter (?)

Post by kenz0 »

Could you post your codes?
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Looping in Rainmeter (?)

Post by csm725 »

kenz0 wrote:Could you post your codes?
Yes, here's the whole skin (apologies for the mess, haven't got around to cleaning it yet...):

Code: Select all

[Rainmeter]
;--------------Deep7 dock by csm725----------------ENJOY!------
Author=csm725
http://csm725.com or http://csm725.deviantart.com
Update=500
DynamicWindowSize=1

[Variables]
Number=5
@include=#SKINSPATH#\deep7dock\UserVariables.inc
pos=0
pos2=9

[pos]
Measure=Calc
Formula=#pos#
DynamicVariables=1

[pos2]
Measure=Calc
Formula=(#pos#+9)
DynamicVariables=1

[PopUp]
Meter=IMAGE
ImageName=popup.png
x=348
y=60
Group=PopUp | RM
;----------------------background------------------------------
[Bg]
Meter=IMAGE
ImageName=bg.png
Group=RM

;---------------------Measures-------------------
[MeasureX]
Measure=FreeDiskSpace
Drive=#Drive1#

[Condition]
Measure=Calc
Formula=#pos# < 18 ? 1 : 0
DynamicVariables=1
IfEqualValue=1
IfEqualAction=!execute [!RainmeterSetVariable pos -10][!RainmeterHideMeterGroup App#pos#]

[Refresh]
Meter=IMAGE
ImageName=refresh.png
x=408
y=73
Group=PopUp
LeftMouseUpAction= !execute [!RainmeterRefresh]
Group=RM

[Config]
Meter=IMAGE
ImageName=config.png
x=20r
y=r
Group=PopUp | RM
LeftMouseUpAction= !execute [#SKINSPATH#/deep7dock/config.exe]

[Close]
Meter=STRING
Group=RM
Text=X
FontColor=0,0,0
FontFace=#FontName#
FontSize=10
StringStyle=Bold
x=20r
Antialias=1
y=-2r
Group=PopUp | RM
LeftMouseUpAction=!RainmeterDeactivateConfig

;--------------------Meters-----------------------

[LeftArrow]
Meter=STRING
Text=«
;#CRLF#%1#CRLF##pos#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=30
AntiAlias=1
x=27
y=17
LeftMouseDownAction=!execute [!RainmeterSetVariable pos (#pos#-1)]
;[!RainmeterHideMeterGroup App1]
DynamicVariables=1
Group=RM

[RightArrow]
Meter=STRING
Text=»
FontColor=#FontColor#
FontFace=#FontName#
FontSize=30
AntiAlias=1
x=800
y=r
LeftMouseDownAction=!execute [!RainmeterSetVariable pos (#pos#+1)][!RainmeterHideMeterGroup App#pos#]
DynamicVariables=1
Group=RM

[App1]
Meter=STRING
Text=#Name1#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
AntiAlias=1
StringAlign=Center
x=103
y=22
StringStyle=Bold
StringCase=#StringTransform#
;Hidden=1
Group=App1
LeftMouseUpAction= !execute ["#Path1#"]
Group=RM

[App1desc]
Meter=STRING
Percentual=1
Postfix=" pct"
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
Group=App1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path1#"]

[App2]
Meter=STRING
Text=#Name2#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path2#"]
Group=App2

[App2desc]
Meter=STRING
Text=#Name2desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
;LeftMouseUpAction=!RainmeterHideMeter "App1desc"
LeftMouseUpAction= !execute ["#Path2#"]
Group=RM
Group=App2

[App3]
Meter=STRING
Text=#Name3#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path3#"]
Group=App3

[App3desc]
Meter=STRING
Text=#Name3desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path3#"]
Group=App3

[App4]
Meter=STRING
Text=#Name4#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
Group=App4
LeftMouseUpAction= !execute ["#Path4#"]


[App4desc]
Meter=STRING
Text=#Name4desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path4#"]
Group=App4

[App5]
Meter=STRING
Text=#Name5#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path5#"]
Group=App5

[App5desc]
Meter=STRING
Text=#Name5desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path5#"]
Group=App5

[App6]
Meter=STRING
Text=#Name6#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path6#"]
Group=App6

[App6desc]
Meter=STRING
Text=#Name6desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path6#"]
Group=App6

[App7]
Meter=STRING
Text=#Name7#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path7#"]
Group=App7

[App7desc]
Meter=STRING
Text=#Name7desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path7#"]
Group=App7

[App8]
Meter=STRING
Text=#Name8#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path8#"]
Group=App8

[App8desc]
Meter=STRING
Text=#Name8desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path8#"]
Group=App8

[App9]
Meter=STRING
Text=#Name9#
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontSize#
StringStyle=Bold
AntiAlias=1
StringAlign=Center
x=83r
y=-22r
StringCase=#StringTransform#
Group=RM
LeftMouseUpAction= !execute ["#Path9#"]
Group=App9

[App9desc]
Meter=STRING
Text=#Name9desc#
MeasureName=MeasureX
FontColor=#DescFontColor#
FontFace=#DescFontName#
FontSize=#DescFontSize#
AntiAlias=1
StringAlign=Center
x=r
y=22r
StringCase=#DescStringTransform#
StringStyle=Bold
Group=RM
LeftMouseUpAction= !execute ["#Path9#"]
Group=App9
User avatar
kenz0
Developer
Posts: 263
Joined: July 31st, 2009, 2:23 pm
Location: Tokyo, JPN
Contact:

Re: Looping in Rainmeter (?)

Post by kenz0 »

Basically, if you change #pos# dynamically using !RainmeterSetVariable, you need to change like this.

[Condition]
Measure=Calc
Formula=#pos# < 18 ? 1 : 0
IfEqualValue=1
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]
DynamicVariables=1

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

here is the sample code.
(when #pos# is less than 6, Group=App#pos#(i.e. Group=5) will be hidden by [Condition].)

Code: Select all

[Variables]
pos=6

[Condition]
Measure=Calc
Formula=#pos# < 6 ? 1 : 0
IfEqualValue=1
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]
DynamicVariables=1

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

[MeterNumber]
Meter=STRING
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=[SetNumber]
DynamicVariables=1

[MeterPrev]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="<"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#-1)


[MeterNext]
Meter=STRING
X=5R
Y=0r
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=">"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#+1)

[MeterObject1]
Meter=STRING
X=0
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object1"
Group=App1

[MeterObject2]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object2"
Group=App2

[MeterObject3]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object3"
Group=App3

[MeterObject4]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object4"
Group=App4

[MeterObject5]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object5"
Group=App5
In this approach, note that the action (!RainmeterSetVariable) is executed only when it changes to 5 from 6.

In addition, as the point that I noticed..

- You have to define multiple group name like "Group=RM | App1"
- When a value is less than 18, the meters named "App17" should be hidden but "App17" doen't exist.

I'm not sure your code may need overhal.
______________________

EDIT:
I improved the above method.

Code: Select all

[Variables]
pos=6

[Condition]
Measure=Calc
Formula=#pos# < 6 ? #pos# : 0
DynamicVariables=1
IfEqualValue=#pos#
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

[MeterNumber]
Meter=STRING
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=[SetNumber]
DynamicVariables=1

[MeterPrev]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="<"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#-1)


[MeterNext]
Meter=STRING
X=5R
Y=0r
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=">"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#+1)


[MeterObject1]
Meter=STRING
X=0
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object1"
Group=App1

[MeterObject2]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object2"
Group=App2

[MeterObject3]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object3"
Group=App3

[MeterObject4]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object4"
Group=App4

[MeterObject5]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object5"
Group=App5
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Looping in Rainmeter (?)

Post by csm725 »

kenz0 wrote:Basically, if you change #pos# dynamically using !RainmeterSetVariable, you need to change like this.

[Condition]
Measure=Calc
Formula=#pos# < 18 ? 1 : 0
IfEqualValue=1
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]
DynamicVariables=1

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

here is the sample code.
(when #pos# is less than 6, Group=App#pos#(i.e. Group=5) will be hidden by [Condition].)

Code: Select all

[Variables]
pos=6

[Condition]
Measure=Calc
Formula=#pos# < 6 ? 1 : 0
IfEqualValue=1
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]
DynamicVariables=1

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

[MeterNumber]
Meter=STRING
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=[SetNumber]
DynamicVariables=1

[MeterPrev]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="<"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#-1)


[MeterNext]
Meter=STRING
X=5R
Y=0r
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=">"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#+1)

[MeterObject1]
Meter=STRING
X=0
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object1"
Group=App1

[MeterObject2]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object2"
Group=App2

[MeterObject3]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object3"
Group=App3

[MeterObject4]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object4"
Group=App4

[MeterObject5]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object5"
Group=App5
In this approach, note that the action (!RainmeterSetVariable) is executed only when it changes to 5 from 6.

In addition, as the point that I noticed..

- You have to define multiple group name like "Group=RM | App1"
- When a value is less than 18, the meters named "App17" should be hidden but "App17" doen't exist.

I'm not sure your code may need overhal.
______________________

EDIT:
I improved the above method.

Code: Select all

[Variables]
pos=6

[Condition]
Measure=Calc
Formula=#pos# < 6 ? #pos# : 0
DynamicVariables=1
IfEqualValue=#pos#
IfEqualAction=!RainmeterHideMeterGroup App[SetNumber]

[SetNumber]
Measure=Calc
Formula=#pos#
Substitute=".00000":""
DynamicVariables=1

[MeterNumber]
Meter=STRING
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=[SetNumber]
DynamicVariables=1

[MeterPrev]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="<"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#-1)


[MeterNext]
Meter=STRING
X=5R
Y=0r
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text=">"
DynamicVariables=1
LeftMouseUpAction=!RainmeterSetVariable pos (#pos#+1)


[MeterObject1]
Meter=STRING
X=0
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object1"
Group=App1

[MeterObject2]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object2"
Group=App2

[MeterObject3]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object3"
Group=App3

[MeterObject4]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object4"
Group=App4

[MeterObject5]
Meter=STRING
X=0r
Y=5R
SolidColor=FFFFFF
FontSize=20
AntiAlias=1
Text="Object5"
Group=App5
Thank you very much! I now look at Calc in a completely different way ;)
Post Reply