It is currently May 7th, 2024, 12:51 pm

Adding leading zeros to a meter

Get help with creating, editing & fixing problems with skins
fenshysa
Posts: 1
Joined: August 20th, 2010, 10:17 pm

Adding leading zeros to a meter

Post by fenshysa »

I'm new to rainmeter and have been learning things as I go. I figured the best way to learn would be to create, so I've been working on a video game themed skin. For the input/output meter I've got it set up to look like the "Score" and "High Score" on an old video game. What I would like to do is have a set number of digits with leading zeros before the numbers. For example:

000000 = 0
001000 = 1,000
100000 = 100,000

The number of leading zeros would have to adjust to compensate so there's always the same amount of number places. That's where I've been running into the problem.

The only information I've been able to find in a search for leading zeros is the leading zero on dates/times. Would I have to use an if/then statement to determine how many leading zeros are added to each number (i.e. if # =< 99 then add "00000")?

Any help or ideas would be greatly appreciated.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Adding leading zeros to a meter

Post by smurfier »

This can be accomplished by dividing by a factor of 10, using the numofdecimals field, and a substitute.

For example, if you want a number with 6 digits:

Code: Select all

[Variables]
Digits=6

[Number]
Measure=Calc
Formula=1234

[Div]
Measure=Calc
Formula=Number/(10**#Digits#)
Substitute="0.":""

[Text]
Meter=String
MeasureName=Div
Numofdecimals=#Digits#
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .