It is currently May 17th, 2024, 6:22 am

String formatting

Get help with creating, editing & fixing problems with skins
Fernir
Posts: 2
Joined: October 16th, 2010, 6:57 am

String formatting

Post by Fernir »

Hello!
I am new in Rainmeter, and I got stuck with my skin. I use a speedometer to display CPU usage, and in the kilometer counter I want to display the current percentage ratio of the CPU stress. It works well, but I want to use leading zeros. There is two way I think:
- In the image I wrote zeros into every place, then I set SolidColor attribute to 0,0,0,255. This way it works, it covers the picture's zeros, but when the pointer should be over it, it's under it - that part is invisible. To better understand, I uploaded a picture:
Image
(In this picture the leading zeros has been already removed from the background picture)
- My other idea is to format somehow the text: if CPU usage is less than 10, then prefix it with two zeros, if less than 100, prefix with one zero. But I haven't found anything related to it in the manual.
Can you help me in it?
Thanks in advance.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: String formatting

Post by poiru »

Fernir wrote:- My other idea is to format somehow the text: if CPU usage is less than 10, then prefix it with two zeros, if less than 100, prefix with one zero. But I haven't found anything related to it in the manual.
Can you help me in it?
Here ya go:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=FFFFFF50

[mCPU]
Measure=CPU

[mCalc]
Measure=Calc
Formula=123000+mCPU
Substitute="123":""

[Text]
Meter=STRING
MeasureName=mCalc
X=5
Y=5
W=100
H=20
Fernir
Posts: 2
Joined: October 16th, 2010, 6:57 am

Re: String formatting

Post by Fernir »

Solution is great :thumbsu:
Now I have just one question: Why it lasts one step? It always shows the previous measure's result. It's not a big problem, but the gauge shows the good value, therefore these differs. (Eg. the gauge shows 66% of usage, this text shows the previous 21%)
User avatar
jsmorley
Developer
Posts: 22633
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: String formatting

Post by jsmorley »

You are going to need to delay the meter showing the "guage" by one update as well, by having it use a calc formula too.

[MeasureDelay]
Measure=Calc
Formula=mCPU

Then use MeasureName=MeasureDelay in your "guage" meter.

Poiru,

Clever... Man, Substitute has some non-intuitive capabilities to jump between string and numeric data types that make it staggeringly useful.