It is currently September 16th, 2024, 7:09 pm

Nested Conditions + Formulas

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Using this to set a shape meter, which works, but it gives four errors, why?
X=([mFUsed:]/[mFTotal:]*150)+15
ERROR: Formula: Division by 0: (7911505920/0*150)+15

The drive is plugged in, so why the zero for mFTotal? The skin shows all details correctly. :???:
Last edited by sl23 on July 19th, 2024, 2:03 pm, edited 3 times in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

I checked WikiHow for how to work out percentages and the formula looks correct as it gives the correct drive percentage that I set it to obtain. But the meter keeps saying in the log that the Total space is zero in the formula. Even though the About/Skins shows it's value?
57686174 77696C6C 6265 77696C6C 6265
User avatar
balala
Rainmeter Sage
Posts: 16549
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Nested Conditions + Formulas

Post by balala »

sl23 wrote: July 18th, 2024, 3:17 pm I'm also trying to figure out why this isn't working:

Code: Select all

Hidden=([#m[#CURRENTSECTION]]=1 ? [UL:W]+2 : [UL:W]#BarW#+2)
Is it incorrect syntax?
sl23 wrote: July 19th, 2024, 10:56 am The second post is still something I would like to get sorted though.
Returning to this: what do you want to do when the condition is not met? I mean that the [UL:W]#BarW#+2 part of the formula (which should be calculated when the value of the appropriate measure is not 1) can't work. Combining together the width of the [UL] meter and the #BarW# variable does nothing. If you meant the product of those you should use the product operation: [UL:W]*#BarW#+2. If you meant something else, please let us know what did you want to achieve.
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Er, so this is the formula without any Variables:
Hidden=(mUpLoad=1 ? [UL:W]+2 : [UL:W]12+2)

So I'm trying to get the meter to basically hide and move position with the above and this X=2R.

If it helps, here's the full skin code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
MouseActionCursor=0
DragGroup=Barred
BackgroundMode=2
SolidColor=#Trans#
DynamicWindowSize=1

[Metadata]
Name=MicroSystem
Author=sl23
Information=CPU, GPU, RAM, Upload, Download, Recycle Bin info + usage.||Speed test:https://www.speedtest.net/result/16504671546
Version=2022.07.16 - 2024.7.16
License=CC BY 3.0

[Variables]
AquaDark=64,191,167,200
Bg=255,255,255,10
Blue=100,100,200,150
GreenAC=100,255,50,130
Trans=0,0,0,1
DLBar=191,159,64
ULBar=191,64,64
GreenCustom=130,230,130,225

Alpha=255
BarColor1=80,64,191,#Alpha#
BarColor2=64,96,191,#Alpha#
BarColor3=64,143,191,#Alpha#
BarColor4=64,191,167,#Alpha#
BarColor5=64,191,96,#Alpha#
BarColor6=104,191,64,#Alpha#
BarColor7=175,191,64,#Alpha#
BarColor8=191,159,64,#Alpha#
BarColor9=191,112,64,#Alpha#
BarColor10=191,64,64,#Alpha#

BarW=8
BarH=46

; Specify Speed in MB/s
DownSpeed=35.00
UpSpeed=10.00

; Specify BinSize in GB
BinSize=10

; Disable specific Bars
mCPU=1
mGPU=0
mRAM=1
mDL=1
mUL=1
mBin=0

========================================
; STYLES
========================================
[sBar]
SolidColor=#AquaDark#
DynamicVariables=1
ToolTipText=~
Hidden=[#m[#CURRENTSECTION]]
X=2R
Y=0
W=#BarW#
H=#BarH#

[sCPUBar]
LeftMouseUpAction=taskmgr.exe
MiddleMouseUpAction=ms-settings:
RightMouseUpAction=

[sNetBar]
LeftMouseUpAction=
MiddleMouseUpAction=ms-settings:network-status
RightMouseUpAction=

========================================
; CPU
========================================
[mCPU]
Measure=CPU
Processor=0
Disabled=[#[#CURRENTSECTION]]

[CPU]
Meter=Bar
MeterStyle=sBar | sCPUBar
MeasureName=mCPU
BarColor=#BarColor1#
ToolTipTitle=CPU: %1
X=0
Y=0

========================================
; GPU
========================================
[mGPU]
Measure=Plugin
Plugin=UsageMonitor
Alias=GPU
Disabled=[#[#CURRENTSECTION]]

[GPU]
Meter=Bar
MeterStyle=sBar | sCPUBar
MeasureName=mGPU
BarColor=#BarColor2#
ToolTipTitle=GPU: [mGPU:0]%

========================================
; RAM
========================================
[mRAMTotal]
Measure=PhysicalMemory
Total=1
UpdateDivider=-1
Disabled=#mRAM#

[mRAM]
Measure=PhysicalMemory
Disabled=[#[#CURRENTSECTION]]

[RAM]
Meter=Bar
MeterStyle=sBar | sCPUBar
MeasureName=mRAM
BarColor=#BarColor3#

[RAMTotal]
Meter=String
MeasureName=mRAM
MeasureName2=mRAMTotal
Text=X
FontColor=#Trans#
AutoScale=1
ToolTipTitle=RAM: %1B / %2B
ToolTipText=~
Hidden=#mRAM#
X=r
Y=r
W=#BarW#
H=#BarH#

========================================
; DL
========================================
[mDL]
Measure=NetIn
Substitute=".0":""
MinValue=0
MaxValue=(#DownSpeed# * 1048576)
Disabled=[#[#CURRENTSECTION]]

[mDLTipScaled]
Measure=Calc
Formula=(( mDL > 1024 ** 3 ) ? ( mDL / ( 1024 ** 3 )) : (( mDL > 1024 ** 2 ) ? ( mDL / ( 1024 ** 2 )) : (( mDL > 1024 ) ? ( mDL / 1024 ) : mDL )))
Substitute=".0":"","0.0":"0"
Disabled=#mDL#

[mDLTipScaledAbr]
Measure=Calc
Formula=(( mDL > 1024 ** 3 ) ? 3 : (( mDL > 1024 ** 2 ) ? 2 : (( mDL > 1024 ) ? 1 : 0 )))
Substitute="3":"GB","2":"MB","1":"KB","0":"B",".0":"","0.0":"0"
Disabled=#mDL#

[DL]
Meter=Bar
MeterStyle=sBar | sNetBar
MeasureName=mDL
BarColor=#BarColor4#
ToolTipTitle=Down: [mDLTipScaled:1] [mDLTipScaledAbr]

========================================
; UL
========================================
[mUL]
Measure=NetOut
Substitute=".0":""
MinValue=0
MaxValue=(#UpSpeed# * 1048576)
Disabled=[#[#CURRENTSECTION]]

[mULTipScaled]
Measure=Calc
Formula=(( mUL > 1024 ** 3 ) ? ( mUL / ( 1024 ** 3 )) : (( mUL > 1024 ** 2 ) ? ( mUL / ( 1024 ** 2 )) : (( mUL > 1024 ) ? ( mUL / 1024 ) : mUL )))
Substitute=".0":"","0.0":"0"
Disabled=#mUL#

[mULTipScaledAbr]
Measure=Calc
Formula=(( mUL > 1024 ** 3 ) ? 3 : (( mUL > 1024 ** 2 ) ? 2 : (( mUL > 1024 ) ? 1 : 0 )))
Substitute="3":"GB","2":"MB","1":"KB","0":"B",".0":"","0.0":"0"
Disabled=#mUL#

[UL]
Meter=Bar
MeterStyle=sBar | sNetBar
MeasureName=mUL
BarColor=#BarColor5#
ToolTipTitle=Up: [mULTipScaled:1] [mULTipScaledAbr]
Hidden=([#m[#CURRENTSECTION]]=1 ? [UL:W]+52 : [UL:W]#BarW#+2)

========================================
; RecycleBin
========================================
[mBinCount]
Measure=RecycleManager
RecycleType=Count
IfCondition=mBinCount = 0
IfTrueAction=[!SetVariable ItemPostfix "s"][!SetOption BinText Text "Empty"]
IfCondition2=mBinCount = 1
IfTrueAction2=[!SetVariable ItemPostfix ""][!SetOption BinText Text "[mBinCount] item"]
IfCondition3=mBinCount > 1
IfTrueAction3=[!SetVariable ItemPostfix "s"][!SetOption BinText Text "[mBinCount] items"]
IfConditionMode=1
Disabled=#mBin#

[mBinItems]
Measure=RecycleManager
RecycleType=Count
Disabled=#mBin#

[mBinSize]
Measure=RecycleManager
RecycleType=Size
MinValue=0
MaxValue=(#BinSize# * 1073741824)
IfCondition=mBinSize < 1024
IfTrueAction=[!SetOption mScaledSize Formula "[mBinSize]"] [!SetVariable ScaleFactor "B"]
IfCondition2=(mBinSize >= 1024) && (mBinSize < 1024**2)
IfTrueAction2=[!SetOption mScaledSize Formula "Round([mBinSize]/1024,2)"] [!SetVariable ScaleFactor "kB"]
IfCondition3=(mBinSize >= 1024**2) && (mBinSize < 1024**3)
IfTrueAction3=[!SetOption mScaledSize Formula "Round([mBinSize]/(1024**2),2)"] [!SetVariable ScaleFactor "MB"]
IfCondition4=(mBinSize >= 1024**3) && (mBinSize < 1024**4)
IfTrueAction4=[!SetOption mScaledSize Formula "Round([mBinSize]/(1024**3),2)"] [!SetVariable ScaleFactor "GB"]
IfCondition5=mBinSize >= 1024**4
IfTrueAction5=[!SetOption mScaledSize Formula "Round([mBinSize]/(1024**4),2)"] [!SetVariable ScaleFactor "TB"]
IfConditionMode=1
Disabled=#mBin#

[mScaledSize]
Measure=Calc
Formula=0
Disabled=#mBin#

[Bin]
Meter=Bar
MeterStyle=sBar
MeasureName=mBinSize
BarColor=#BarColor6#
LeftMouseUpAction=[!CommandMeasure mBinCount "OpenBin"]
MiddleMouseUpAction=[!CommandMeasure "mBinProperties" "Properties shell:::{645FF040-5081-101B-9F08-00AA002F954E}"]
RightMouseUpAction=[!CommandMeasure mBinCount "EmptyBin"]
ToolTipTitle=Bin: [mBinCount] item#ItemPostfix# - [mScaledSize] #ScaleFactor#
The idea is to use the #Disabled# Variable to hide meters you don't want to use. At the same time, move the ones on the right, to the left of the previous meter that is shown. But leaving a small gap of 2 pixels between them.

Each Bar has a width and a 2pixel spacer. When you hide one of the bars, it hides the Bar and the spacer, thus moving the Bars on the right to the left by #BarW#+2. Hope that makes sense?

Thanks. :)
Last edited by sl23 on July 19th, 2024, 3:12 pm, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Nested Conditions + Formulas

Post by Yincognito »

sl23 wrote: July 19th, 2024, 10:56 am but getting an errors on every update saying the formula is wrong for every drive unplugged! :x
This one here is where (and why) you should add that 0.00001 'epsilon' value to the divisor to avoid the division by 0 error, like already mentioned.
sl23 wrote: July 19th, 2024, 1:37 pm Using this to set a shape meter, which works, but it gives four errors, why?
X=([mFUsed:]/[mFTotal:]*150)+15
ERROR: Formula: Division by 0: (7911505920/0*150)+15

The drive is plugged in, so why the zero for mFTotal? The skin shows all details correctly. :???:
This one is different from the above. It's probably an error appearing in the log at skin load / refresh time, when the measure didn't yet get the drive's total size. No need to worry about this one, unlike the one above, especially if things work otherwise.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Ok thanks, I just don't like having the errors! :(

Edit: Just searched for Epsilon, I missed that part of the post, sorry.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Nested Conditions + Formulas

Post by Yincognito »

sl23 wrote: July 19th, 2024, 2:28 pm Ok thanks, I just don't like having the errors! :(

Edit: Just searched for Epsilon, I missed that part of the post, sorry.
https://forum.rainmeter.net/search.php?keywords=Epsilon&terms=all&author=Yincognito&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search

It's up to you to 'get it', I already explained its purpose, and you have it used in multiple skins already.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

Yeah that's what I meant, I missed that part! :thumbup:

I know, I'm trying, but it's difficult when you don't know the way these things work, there limits, what you can and can't do. :)
The manual doesn't give much info on formulas and what does/doesn't work inside them, as it's assumed you know what you're doing.
But what are the limits of using Section Variables in them? Is there any info on what can/can't be done? Like combining things like above into something like this: X=([mFTotal]<1 ? 0.00001 : (([mFUsed:]/[mFTotal:]*150)+15)) :confused:
Last edited by sl23 on July 19th, 2024, 2:44 pm, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Nested Conditions + Formulas

Post by Yincognito »

sl23 wrote: July 19th, 2024, 2:38 pm Yeah that's what I meant, I missed that part! :thumbup:
I don't know how you could have missed it, since you were the one asking for an explanation on it in the first place... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1686
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Nested Conditions + Formulas

Post by sl23 »

It was a one liner and I was focusing on the solution to my problem at the time, sorry bout that. :oops:
57686174 77696C6C 6265 77696C6C 6265