It is currently July 23rd, 2024, 3:53 am

String Meter: Significant figures

Get help with creating, editing & fixing problems with skins
greensheep
Posts: 1
Joined: June 19th, 2010, 1:58 pm

String Meter: Significant figures

Post by greensheep »

Hi,

I have a meter displaying my cpu usage as a percentage. When the usage is >10%, (37%, for example) two digits are used. When the usage is <10%, however (e.g. 5%) only one digit is used. My question is, then, how does one manipulate the skin's code so that the meter is displayed to 2 significant figures at all times?
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: String Meter: Significant figures

Post by JpsCrazy »

In the Measure, add:
Substitute="1":"01","2":"02","3":"03",etc...
Do that up to 9, and it may take a little tinkering.

Search for Substitutes if you need more help on it.
User avatar
kenz0
Developer
Posts: 263
Joined: July 31st, 2009, 2:23 pm
Location: Tokyo, JPN

Re: String Meter: Significant figures

Post by kenz0 »

Try this

Code: Select all

[MeasureCPU]
Measure=CPU

[MeasureCalc]
Measure=Calc
Formula=MeasureCPU / 10
Substitute=".":""

[MeterCPU]
Meter=STRING
MeasureName=MeasureCalc
NumOfDecimals=1
.
Image
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: String Meter: Significant figures

Post by poiru »

JpsCrazy wrote:Substitute="1":"01","2":"02","3":"03",etc...
Do that up to 9, and it may take a little tinkering.
That wouldn't work (11% CPU would become 0101%).. :)
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: String Meter: Significant figures

Post by JpsCrazy »

poiru wrote: That wouldn't work (11% CPU would become 0101%).. :)
That's very, very true.
Well, I think kenz0's way would work.