It is currently April 25th, 2024, 8:09 am
Round [Mesure] to an integer
-
- Posts: 6
- Joined: January 15th, 2021, 2:03 pm
Round [Mesure] to an integer
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.
-
- Posts: 92
- Joined: July 18th, 2020, 1:23 am
- Location: California
Re: Round [Mesure] to an integer
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.
-
- Rainmeter Sage
- Posts: 16168
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Round [Mesure] to an integer
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
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
-
- Posts: 92
- Joined: July 18th, 2020, 1:23 am
- Location: California
Re: Round [Mesure] to an integer
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.
-
- Posts: 6
- Joined: January 15th, 2021, 2:03 pm
Re: Round [Mesure] to an integer
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!jsmorley wrote: ↑February 4th, 2021, 11:25 am https://docs.rainmeter.net/manual/variables/section-variables/#MeasureParameters
-
- Rainmeter Sage
- Posts: 16168
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Round [Mesure] to an integer
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.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.