It is currently March 23rd, 2023, 8:44 pm

## Regarding If conditions

Get help with creating, editing & fixing problems with skins Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Regarding If conditions

Code: Select all

``````[UsedHDD1Measure]
Measure=FreeDiskSpace
Drive=C:
InvertMeasure=1

[FreeHDD1Measure]
Measure=FreeDiskSpace
Drive=C:

[TotalHDD1Measure]
Measure=FreeDiskSpace
Drive=C:
Total=1

[HDD1Calc]
Measure=Calc
Formula=((FreeHDD1Measure / TotalHDD1Measure) * 100)
ifcondition=HDD1Calc>50
IfTrueAction=!setvariable Bclr "147, 188, 118"
ifcondition2=HDD1Calc<50 && HDD1Calc>15
IfTrueAction2=!setvariable Bclr "213, 180, 117"
ifcondition3=HDD1Calc<14
IfTrueAction3=!setvariable Bclr "224, 108, 117"
``````

Code: Select all

``````[Drive1bar]
meter=bar
BarColor=#Bclr#
Solidcolor=59, 66, 82
W=150
H=15
X=-40r
Y=55r
MeasureName=MeasureUsedDiskSpace
Barorientation=Horizontal
DynamicVariables=1``````
i was trying to change the colors of the bar depending on the percentage of storage in that drive like green for above 50% and yellow for below 50% but above 15% and red for below 15%. I really think i have made a small mistake somewhere but I just cant find it BOOTY Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Re: Regarding If conditions

I just figured it out !
I forgot to put the 2 in the formula for the calc measure to caluclate the percentage Last edited by Alloutofmercy on October 6th, 2022, 3:37 pm, edited 1 time in total.
BOOTY balala
Rainmeter Sage
Posts: 15059
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Regarding If conditions

Alloutofmercy wrote: October 6th, 2022, 2:33 pm I forgot to put the 2 in the formula for the calc measure to caluclate the percentage ! I don't know what 2 have you forget, but I doubt you got the code properly work, because there still are some issues.
For instance the IfCondition and IfCondition3 are correct, however IfCondition2 is not. If there are more conditions into one single IfCondition, the conditions have to be included into parenthesis. My advice is to always include all conditions into parenthesis, but this is not absolutely mandatory. However at least the ones which can't work without parenthesis, for sure have to be included.
Here is what am I talking about:

Code: Select all

``````[HDD1Calc]
...
IfCondition=(HDD1Calc>50)
...
IfCondition2=((HDD1Calc<50) && (HDD1Calc>15))
...
IfCondition3=(HDD1Calc<14)
...``````
As said the paranthesis in the IfCondition and IfConditioon3 are optional (but recommended), as well as the first and last parenteses of IfCondition2 (the green ones here: IfCondition2=((HDD1Calc<50) && (HDD1Calc>15))). The red ones are mandatory. Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Re: Regarding If conditions

Code: Select all

``````[Variables]
red=224, 108, 117
yellow=213, 180, 117
green=130, 165, 108

[MeasureUsedDiskPercentual]
Measure=Calc
Formula=Round(([MeasureUsedDiskSpace:]/[MeasureTotalDiskSpace:])*100,2)
DynamicVariables=1
...
IfCondition=(MeasureUsedDiskPercentual>50)
...
IfTrueAction=[!SetVariable "Bclr" "#green#"][!update]

IfCondition2=((MeasureUsedDiskPercentual<50) && (MeasureUsedDiskPercentual>15))
...
IfTrueAction2=[!SetVariable "Bclr" "#yellow#"][!update]

IfCondition3=(MeasureUsedDiskPercentual<14)
...
IfTrueAction3=[!SetVariable "Bclr" "#red#"][!update]

OnUpdateAction=[!UpdateMeter Drive1bar][!Redraw]

[Drive1bar]
meter=bar
BarColor=#Bclr#
Solidcolor=59, 66, 82
W=150
H=15
X=-40r
Y=55r
MeasureName=MeasureUsedDiskSpace
Barorientation=Horizontal
DynamicVariables=1
Flip=0

``````
Hmm i did that now and renamed the measures a little bit but it is still stuck on green
Screenshot 2022-10-06 083536.png
You do not have the required permissions to view the files attached to this post.
BOOTY balala
Rainmeter Sage
Posts: 15059
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Regarding If conditions

Alloutofmercy wrote: October 6th, 2022, 3:37 pm Hmm i did that now and renamed the measures a little bit but it is still stuck on green
What 70.5 GB is (from your screenshot)? It's the free- or the used space? Please post the whole code if you want us to can help.
However, I believe you've made a mistake in the posted code: if in the Formula option of the [MeasureUsedDiskPercentual] measure you're dividing the used disk space ([MeasureUsedDiskSpace]) by the total ([MeasureTotalDiskSpace:]), you get the percent of used space (obviously). In my opinion the color should be set to green when the FREE disk space is above 50%, to yellow below this and finally to red when this percent is below 15%. But since your measure calculates the percent of used disk space, this is done exactly opposite: the color is set to green when the drive has a greater used space than 50%, to yellow, between 50% and 15% and finally to red below 15%. I think you've mixed a little bit the conditions and the corresponding color settings. Please check. Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Re: Regarding If conditions

It is used space / total space
yes I want it to be green for above 50%, yellow for below 50 and above 15% and red for below 15%.

If condition states that if the MeasureUsedDiskPercentual value is greater than 50
then if true setvariable "Bclr" to #green# in this code

Code: Select all

``````[MeasureUsedDiskPercentual]
Measure=Calc
Formula=Round(([MeasureUsedDiskSpace:]/[MeasureTotalDiskSpace:])*100,2)
DynamicVariables=1
...
IfCondition=(MeasureUsedDiskPercentual>50)
...
IfTrueAction=[!SetVariable "Bclr" "#green#"][!update]

IfCondition2=((MeasureUsedDiskPercentual<50) && (MeasureUsedDiskPercentual>15))
...
IfTrueAction2=[!SetVariable "Bclr" "#yellow#"][!update]

IfCondition3=(MeasureUsedDiskPercentual<14)
...
IfTrueAction3=[!SetVariable "Bclr" "#red#"][!update]

OnUpdateAction=[!UpdateMeter Drive1bar][!Redraw]``````
but 70gb of 75 gb is far greater than 50%
BOOTY balala
Rainmeter Sage
Posts: 15059
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Regarding If conditions

Alloutofmercy wrote: October 7th, 2022, 8:01 am but 70gb of 75 gb is far greater than 50%
Believe me, Rainmeter (as well as a programming language, any of them) doesn't fail in calculations of this type. If the value of the [MeasureUsedDiskPercentual] measure is greater than 50%, the Bclr variable is set to #green# for sure.
So, post please the code of the [MeasureUsedDiskSpace] and [MeasureTotalDiskSpace] measures, because you didn't post them. Yep, I know you did post the [UsedHDD1Measure], [FreeHDD1Measure] and [TotalHDD1Measure] measures, but in meantime you've changed the names of measures, so could be useful to see the measures as you're using them. Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Re: Regarding If conditions

Code: Select all

``````[MeasureTotalDiskSpace]
Measure=FreeDiskSpace
Drive=C:
Total=1
UpdateDivider=5
percentual=1
MinValue=0
Maxvalue=100

[MeasureUsedDiskSpace]
Measure=FreeDiskSpace
Drive=C:
InvertMeasure=1
UpdateDivider=5
percentual=1
MinValue=0
Maxvalue=100

[MeasureDiskLabel]
Measure=FreeDiskSpace
Drive=C:
Label=1
UpdateDivider=5

[MeasureUsedDiskPercentual]
Measure=Calc
Formula=Round(([MeasureUsedDiskSpace:]/[MeasureTotalDiskSpace:])*100,2)
DynamicVariables=1
...
IfCondition=(MeasureUsedDiskPercentual>50)
...
IfTrueAction=[!SetVariable "Bclr" "#green#"][!update]

IfCondition2=((MeasureUsedDiskPercentual<50) && (MeasureUsedDiskPercentual>15))
...
IfTrueAction2=[!SetVariable "Bclr" "#yellow#"][!update]

IfCondition3=(MeasureUsedDiskPercentual<14)
...
IfTrueAction3=[!SetVariable "Bclr" "#red#"][!update]

OnUpdateAction=[!UpdateMeter Drive1bar][!Redraw]``````

Code: Select all

``````[Lback]
meter=Shape
Shape=Rectangle 5,150,170,250,#curve# | Fillcolor 40,44,52,#alpha# | Strokewidth 0 | StrokeColor 59,66,82

[Drive1image]
meter=image
Imagename=#@#HDD.png
X=10
Y=170
W=40
imagetint=59, 66, 82

[Drive1string]
meter=String
FontFace=Jetbrains mono
Fontsize=15
Fontcolor=ffffff
AntiAlias=1
X=40r
Y=r

[Drive1bar]
meter=bar
BarColor=#Bclr#
Solidcolor=59, 66, 82
W=150
H=15
X=-35r
Y=55r
MeasureName=MeasureUsedDiskSpace
Barorientation=Horizontal
DynamicVariables=1
Flip=0

[gbstring]
meter=String
Text=%1B/%2B Used
MeasureName=MeasureUsedDiskSpace
MeasureName2=MeasureTotalDiskSpace
X=15
Y=250
AutoScale=1
FontFace=Jetbrains mono
Fontsize=9
Fontcolor=fffff
AntiAlias=1
NumOfDecimals=1

[Labeldrive]
meter=String
Fontsize=11
Fontcolor=ffffff
FontFace=Jetbrains mono
Y=185
X=50
MeasureName=MeasureDiskLabel
Text=%1
AntiAlias=1
``````

Code: Select all

``````[Variables]
curve=8
1=C:
red=224, 108, 117
yellow=213, 180, 117
green=130, 165, 108
browser=Chrome
browserpath=Chrome.exe
alpha=255``````
BOOTY balala
Rainmeter Sage
Posts: 15059
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Regarding If conditions

Alloutofmercy wrote: October 7th, 2022, 8:01 am but 70gb of 75 gb is far greater than 50%
Now taking a look at the posted codes of all those measures, meters and variables, I'm not sure anymore what is the problem. You have a used space of 70.5 GB from a total of 75.9 GB. This is far above 50%. Accordingly, the Bclr variable is set to #green#, as the IfCondition / IfTrueAction options state this. So, what is the problem? Alloutofmercy
Posts: 139
Joined: November 17th, 2021, 5:51 am

### Re: Regarding If conditions

Oh sh*t I am so stupid

ah iwanted it to be green when the free space is above 50% but made it become green if it was above 50% of used space !

i think i just have to switch it to percentage of freespace measure
BOOTY