It is currently April 25th, 2024, 8:09 am

Round [Mesure] to an integer

Get help with creating, editing & fixing problems with skins
Rbuha
Posts: 6
Joined: January 15th, 2021, 2:03 pm

Round [Mesure] to an integer

Post by Rbuha »

Hello. How do I round the data to an integer in [Ms_CPU]? I need to use [Ms_CPU] as a path variable in BarImage.

Code: Select all

[Ms_CPU] 
Measure = CPU 
Processor = 0
[M_Bar] 
MeasureName = Ms_CPU
Meter = Bar 
Y = 3 R 
W = 250 
H = 30 
BarImage=#@#\1\[Ms_CPU].png
SolidColor = 150 , 150 , 150 , 255 
BarOrientation = Horizontal
DynamicVariables=1
User avatar
Alex88
Posts: 92
Joined: July 18th, 2020, 1:23 am
Location: California

Re: Round [Mesure] to an integer

Post by Alex88 »

Rbuha wrote: February 4th, 2021, 7:19 am Hello. How do I round the data to an integer in [Ms_CPU]? I need to use [Ms_CPU] as a path variable in BarImage.
...
See balala's answer below instead

One way is to add another Calc measure [Ms_CPU_Round] that uses Round(x, precision). Other options are using the floor, ceiling, and truncating; see the full list at Formulas.

Code: Select all

[Ms_CPU]
Measure = CPU
Processor = 0

[Ms_CPU_Round]
Measure = Calc
Formula = Round(Ms_CPU)

[M_Bar]
MeasureName = Ms_CPU
Meter = Bar
Y = 3 R
W = 250
H = 30
BarImage=#@#\1\[Ms_CPU_Round].png
SolidColor = 150 , 150 , 150 , 255
BarOrientation = Horizontal
DynamicVariables=1
Last edited by Alex88 on February 4th, 2021, 11:24 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round [Mesure] to an integer

Post by balala »

Rbuha wrote: February 4th, 2021, 7:19 am How do I round the data to an integer in [Ms_CPU]? I need to use [Ms_CPU] as a path variable in BarImage.
Another solution beside Alex88's idea is to not use an additional Calc measure, but to round the value of the measure directly into the Bar meter. Something like this:

Code: Select all

[Ms_CPU] 
Measure=CPU 
Processor=0

[M_Bar] 
MeasureName=Ms_CPU
Meter=Bar
Y=3R
W=250
H=30
BarImage=#@#\1\[Ms_CPU:0].png
SolidColor=150,150,150,255 
BarOrientation=Horizontal
DynamicVariables=1
See the updated BarImage option: BarImage=#@#\1\[Ms_CPU:0].png. The [Ms_CPU:0] section variable always returns the rounded value.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Round [Mesure] to an integer

Post by jsmorley »

User avatar
Alex88
Posts: 92
Joined: July 18th, 2020, 1:23 am
Location: California

Re: Round [Mesure] to an integer

Post by Alex88 »

balala wrote: February 4th, 2021, 11:17 am Another solution beside Alex88's idea is to not use an additional Calc measure, but to round the value of the measure directly into the Bar meter.
...
I knew there was a more simple way that I was missing, forgot about the decimal parameter on section variables, definitely the better way here. If you wanted to do more complicated things to the number, full expressions, then that's when you would have a separate Calc measure.
Rbuha
Posts: 6
Joined: January 15th, 2021, 2:03 pm

Re: Round [Mesure] to an integer

Post by Rbuha »

Alex88 wrote: February 4th, 2021, 10:11 am See balala's answer below instead

One way is to add another Calc measure [Ms_CPU_Round] that uses Round(x, precision). Other options are using the floor, ceiling, and truncating; see the full list at Formulas.
balala wrote: February 4th, 2021, 11:17 am Another solution beside Alex88's idea is to not use an additional Calc measure, but to round the value of the measure directly into the Bar meter. Something like this.
See the updated BarImage option: BarImage=#@#\1\[Ms_CPU:0].png. The [Ms_CPU:0] section variable always returns the rounded value.
Thank you all so much for your help!
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round [Mesure] to an integer

Post by balala »

Alex88 wrote: February 4th, 2021, 10:28 pm I knew there was a more simple way that I was missing, forgot about the decimal parameter on section variables, definitely the better way here. If you wanted to do more complicated things to the number, full expressions, then that's when you would have a separate Calc measure.
Using a distinct Calc measure is definitely not a bad solution. It is widly used and in most cases it is much simpler, than using the section variables. My proposal was just an idea about another solution of the same problem.