It is currently March 29th, 2024, 11:51 am

Number measure extension "0"

Get help with creating, editing & fixing problems with skins
Mekurukito
Posts: 21
Joined: July 8th, 2018, 6:09 am

Number measure extension "0"

Post by Mekurukito »

how can i make a measureable number with additional "0" on the displayed text? :???:
example : displayed "0005" second instead "5" second , displayed "050.5" gb instead "50.5" gb

if its cannot be undone, can i make an extra string instead for the "0" extension?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Number measure extension "0"

Post by balala »

Mekurukito wrote: November 13th, 2019, 11:33 am how can i make a measureable number with additional "0" on the displayed text? :???:
example : displayed "0005" second instead "5" second , displayed "050.5" gb instead "50.5" gb

if its cannot be undone, can i make an extra string instead for the "0" extension?
It can be, you just have to add a substitution to the measure which returns the number. For instance with the following two options added, the measure will get three zeros before the number:

Code: Select all

[MeasureSomething]
...
RegExpSubstitute=1
Substitute="^(.*)$":"000\1"
This adds three zeros, because in the Substitute option I added three zeros in front of \1. If you want a different number of zeros, add the appropriate number of zeros.
Mekurukito
Posts: 21
Joined: July 8th, 2018, 6:09 am

Re: Number measure extension "0"

Post by Mekurukito »

thank you for the answer, i have a new question

is it possible to delete disk symbol "g"?
example : it show "5.0" instead of "5.0 G"
Mekurukito
Posts: 21
Joined: July 8th, 2018, 6:09 am

Re: Number measure extension "0"

Post by Mekurukito »

balala wrote: November 13th, 2019, 12:54 pm It can be, you just have to add a substitution to the measure which returns the number. For instance with the following two options added, the measure will get three zeros before the number:

Code: Select all

[MeasureSomething]
...
RegExpSubstitute=1
Substitute="^(.*)$":"000\1"
This adds three zeros, because in the Substitute option I added three zeros in front of \1. If you want a different number of zeros, add the appropriate number of zeros.
i think this is not a good solve for what i aiming
i want to make it real calculation,
like its supposed to be "062gb" not "00062gb"...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Number measure extension "0"

Post by balala »

Mekurukito wrote: November 13th, 2019, 1:53 pm is it possible to delete disk symbol "g"?
example : it show "5.0" instead of "5.0 G"
Please post a complete code. I suppose in the above string ("5.0 G"), the G is not the disk symbol, but a scaling Giga prefix. If this is so, the G is introduced by the String meter, through an AutoScale=1 option, so there is nothing to be deleted.
Anyway first a code would be needed. Please post it.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Number measure extension "0"

Post by balala »

Mekurukito wrote: November 13th, 2019, 2:01 pm like its supposed to be "062gb" not "00062gb"...
You mean the number of zeros should depend on how many letters (symbols, characters) are in the string? I'm not sure I understood this request.
Mekurukito
Posts: 21
Joined: July 8th, 2018, 6:09 am

Re: Number measure extension "0"

Post by Mekurukito »

balala wrote: November 13th, 2019, 3:09 pm You mean the number of zeros should depend on how many letters (symbols, characters) are in the string? I'm not sure I understood this request.
Yeah, its suppose to be depend on the number, like a digital clock it can show like "00:30" but im trying if i can do it for a simple measure number like measuring total of hard drive data
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Number measure extension "0"

Post by Yamajac »

This is extremely simple.

Code: Select all

[Rainmeter]
Update = -1

[DoIt]
Measure = String
String = 34
RegExpSubstitute = 1

; Add as many zeroes as you want
; Just make sure you add enough to get as many digits
; as you plan to have.

; The first substitute grabs the entire string and adds zeroes to the front
; The second substitute grabs the last four numbers
; For more/less numbers just change the {4} to whatever you want
Substitute = "(.*)" : "0000000\1", ".*[0-9]([0-9]{4})" : "\1"

[ShowIt]
Meter = String
Text = [DoIt]
FontSize = 15

[DoItTrailing]
Measure = String
String = 34gb
RegExpSubstitute = 1

; Add as many zeroes as you want
; Just make sure you add enough to get as many digits
; as you plan to have.

; The first substitute grabs the entire string and adds zeroes to the front
; The second substitute grabs the last four numbers as well as the trailing text
; For more/less numbers just change the {4} to whatever you want
Substitute = "(.*)" : "0000000\1", ".*[0-9]([0-9]{4})(.*)" : "\1\2"

[ShowItTrailing]
Meter = String
Text = [DoItTrailing]
Y = 20r
FontSize = 15

I left comments so it should be reasonably simple to understand.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Number measure extension "0"

Post by Yamajac »

Actually, I overengineered it just a little bit.

If you change the name of the DoIt measure make sure you change the [DoIt:MinValue] as well to reflect the new name in the third substitute. If you name the measure ZeroLeader then change it to [ZeroLeader:MinValue]. Doesn't matter, just make sure you're aware. Can't use #CURRENTSECTION# in a regex so gotta do it manually unfortunately.
Substitute = "(.*)" : "000000000000\1", "^(0*)(.*)" : "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\2", ".*[0-9]([0-9]{[DoIt:MinValue]}.*)" : "\1"


You can change how much padding you have by changing the MinValue on the [DoIt] measure. You can do this by manually typing it in, or by using the !SetOption bang. Change that number to however many digits you want, total. If you want 0023 then that's 4.

Then make sure that DoIt gets the right text in the String option, either by using DynamicVariables with the name of a measure/variable as a parameter or through the use of !SetOption or the like.


Any trailing text after the number will be preserved - gb, kb, mb, am, pm, whatever.


If you need help making it work then just lemme know, but try to be more descriptive and provide code examples.

Code: Select all

[Rainmeter]
Update = -1

[DoIt]
Measure = String
String = 34gb
RegExpSubstitute = 1
MinValue = 4
; The first substitute grabs the entire string and adds zeroes to the front
; The second substitute grabs the leading zeroes and duplicates them several times
; to ensure we have enough leading zeroes for all use cases
; Then finally the third substitute removes all but the last X digits
; Where X is the MinValue on this measure
Substitute = "(.*)" : "000000000000\1", "^(0*)(.*)" : "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\2", ".*[0-9]([0-9]{[DoIt:MinValue]}.*)" : "\1"

[ShowIt]
Meter = String
Text = [DoIt]
FontSize = 15
SolidColor = 0,0,0,1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Number measure extension "0"

Post by balala »

Mekurukito wrote: November 14th, 2019, 2:48 am Yeah, its suppose to be depend on the number, like a digital clock it can show like "00:30" but im trying if i can do it for a simple measure number like measuring total of hard drive data
Instead of an overcomplicated approach, I'd use a following kind of substitution: Substitute="^(.{5})$":"0\1","^(.{4})$":"00\1","^(.{3})$":"000\1","^(.{2})$":"0000\1","^(.{1})$":"00000\1".
What this substitution does?
First it checks if the value returned by the measure where it is added has five characters (in the .{5} expression, . means any character, {5} means there are five characters). If the value has indeed five characters, this substitution is made and in front of the string (wrote as \1 in the second part of the substitution) is added a zero. If the string has four characters, the first substitution is ignored, but the second one is executed. In this case two zeros are added before the string (due to the 00\1 value). Same way, if there are three characters, three zeros are added (being executed the "^(.{3})$":"000\1" substitution), for two characters four zeros ("^(.{2})$":"0000\1") and finally for one single character, five zeros are added ("^(.{1})$":"00000\1").
Obviously you have to rewrite the zeros if different number of them are required. And further substitutions are also required if more zeros have to be added. But this is the basic of a such procedure to get zeros in front of the string returned by a measure.