I've gone through the docs, I've searched, I've googled, I've skimmed the skin archives looking for someone who may have done this so I can 'borrow' the code, and hours later I've come up empty.
So here I am asking for help.
I've got a RAM and SWAP Meter that displays the values via String working fine. However due to the size of my skin I'd like to be able to remove the spaces between the value and the "byte" representation to save a bit of space.
Can this be done?
If yes, please show me how oh wise Rainmeter gurus!
TL;DR
String Meter...
What I have: 2.3 GB
What I want: 2.3GB (No space between the number and GB)
It is currently April 26th, 2024, 12:46 am
[Solved] Question: String Meter val manip - Remove space?
-
- Posts: 56
- Joined: February 5th, 2014, 3:44 pm
- Location: Canada
[Solved] Question: String Meter val manip - Remove space?
Last edited by Grim on February 12th, 2014, 5:42 pm, edited 2 times in total.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Question: String Meter value manipulation - Remove space
Assuming you are using the AutoScale option on the meter to scale the value, then really no. The space is added automatically when the meter is drawn, and there is no way to suppress it. You would instead need to use the Scale option, and tell it the amount you want to scale the number. Then you can set any text you want on the meter, by using the Text option with %1 for the value returned by MeasureName on the meter. This is going to be quite a bit less flexible than AutoScale, since you will have to make an assumption that the value is always going to be megabytes or gigabytes or whatever works best.
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Question: String Meter value manipulation - Remove space
Here's the scary math solution.
Code: Select all
[Variables]
Decimals=2
[num]
Measure=Calc
Formula=1563154794265
[Scale]
Measure=Calc
Formula=num=0?1:ceil(log(num)/(10*log(2)))
Substitute="1":"B","2":"kB","3":"mB","4":"gB","5":"tB","6":"pB","7":"eB","8":"zB","9":"yB"
[Scaled]
Measure=Calc
Formula=round(num/1024**(Scale-1),#Decimals#)
[String]
Meter=String
MeasureName=Scaled
MeasureName2=Scale
NumOfDecimals=#Decimals#
Text=%1%2
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 . . .
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 . . .
-
- Posts: 56
- Joined: February 5th, 2014, 3:44 pm
- Location: Canada
Re: Question: String Meter value manipulation - Remove space
I am using AutoScale, and damn. 3.1 feature request?jsmorley wrote:Assuming you are using the AutoScale option on the meter to scale the value, then really no. The space is added automatically when the meter is drawn, and there is no way to suppress it. You would instead need to use the Scale option, and tell it the amount you want to scale the number. Then you can set any text you want on the meter, by using the Text option with %1 for the value returned by MeasureName on the meter. This is going to be quite a bit less flexible than AutoScale, since you will have to make an assumption that the value is always going to be megabytes or gigabytes or whatever works best.
smurfier wrote:Here's the scary math solution.
8< Snip, will play with this and see.
Thanks for the quick responses.
Edit: Took the 'B' out of my Text. Saved some room there.
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: Question: String Meter value manipulation - Remove space
Perhaps this would be a cool addition to the String measure. Let it behave kind of like a String meter only that it's not displayed. This means let it use AutoScale and %1 etc. to insert values of other measures, then edit the result by Substitute/RegExpSubstitute.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
-
- Posts: 56
- Joined: February 5th, 2014, 3:44 pm
- Location: Canada
Re: Question: String Meter value manipulation - Remove space
So I found a solution to this that's way simple using a Substitute on the Measure.
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
Full working code example with measures and meters.
Edit: Thanks to the creator of the following skin for the snippet.
http://goatrance.deviantart.com/art/The-professional-312277079
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
Full working code example with measures and meters.
Code: Select all
[MeasurePMUsed]
Measure=PhysicalMemory
UpdateDivider=2
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
[MeasurePMFree]
Measure=PhysicalMemory
InvertMeasure=1
UpdateDivider=2
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
[MeasurePMTotal]
Measure=PhysicalMemory
Total=1
UpdateDivider=-1
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
[MeterPMTextUsed]
Meter=String
MeasureName=MeasurePMUsed
X=5
Y=r
FontColor=00FF00
NumOfDecimals=1
AutoScale=1
Text="RAM Used: %1"
[MeterPMTextFree]
Meter=String
MeasureName=MeasurePMFree
X=r
Y=R
FontColor=00FF00
NumOfDecimals=1
AutoScale=1
Text="RAM Free: %1"
[MeterPMTextTotal]
Meter=String
MeasureName=MeasurePMTotal
X=r
Y=R
FontColor=00FF00
NumOfDecimals=1
AutoScale=1
Text="RAM Total: %1"
http://goatrance.deviantart.com/art/The-professional-312277079
-
- Posts: 56
- Joined: February 5th, 2014, 3:44 pm
- Location: Canada
Re: Question: String Meter value manipulation - Remove space
Simpler still...Grim wrote:So I found a solution to this that's way simple using a Substitute on the Measure.
Substitute=" K":"K"," M":"M"," G":"G"," T":"T"
Substitute=" ":""
Tested in the skin I'm working on and works on FreeDiskSpace, Memory, and Net Measures.
Was sure I tested this before posting the OP and it wasn't working, but it works now.
-
- Posts: 1740
- Joined: November 13th, 2012, 9:53 pm
Re: [Solved] Question: String Meter val manip - Remove space
haha
i would not have gotten this idea. but it makes sense, as the meter of course does not to the scaling and the value is already there in the measure.
i would not have gotten this idea. but it makes sense, as the meter of course does not to the scaling and the value is already there in the measure.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: [Solved] Question: String Meter val manip - Remove space
The routines for Subsitute and AutoScale are both in the underlying code for measures (Measure.cpp in the C++), but they are "called" by the meters when the value is "used". Just so happens that Substitute is done last. This is a nice trick that also never occurred to me before.
-
- Posts: 56
- Joined: February 5th, 2014, 3:44 pm
- Location: Canada
Re: [Solved] Question: String Meter val manip - Remove space
Tips and Tricks!jsmorley wrote:The routines for Subsitute and AutoScale are both in the underlying code for measures (Measure.cpp in the C++), but they are "called" by the meters when the value is "used". Just so happens that Substitute is done last. This is a nice trick that also never occurred to me before.