It is currently April 25th, 2024, 5:16 am

String to number from RunCommand

Get help with creating, editing & fixing problems with skins
derari
Posts: 17
Joined: February 24th, 2011, 5:39 pm

String to number from RunCommand

Post by derari »

I have a RunCommand that returns a number as a string value, but I would like to format the value as a number in a string meter.

However, the formatting options have no effect. The meter shows the plain result of the measure.

Example below, how can I fix this?

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure measureL2Cache "Run"]

[Metadata]
Name=Test

[measureL2Cache]
; returns "1024"
Measure=Plugin
Plugin=RunCommand
Parameter=wmic path Win32_Processor get L2CacheSize /VALUE
State=Hide
OutputType=ANSI
RegExpSubstitute=1
Substitute=".*?=":"","#CRLF#":""
UpdateDivider=-1

[meterL2Cache]
;prints "1024 MB" instead of "1.0 MB"
Meter=String
W=200
MeasureName=measureL2Cache
Text=%1 MB
Scale=1024
NumOfDecimals=1
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: String to number from RunCommand

Post by balala »

derari wrote: December 18th, 2018, 11:55 am However, the formatting options have no effect. The meter shows the plain result of the measure.

Example below, how can I fix this?
Add a Calc measure, which makes the needed conversion:

Code: Select all

[measureL2CacheNum]
Measure=Calc
Formula=[measureL2Cache]
DynamicVariables=1
Now use the value returned by this measure into the String meter:

Code: Select all

[meterL2Cache]
...
MeasureName=measureL2CacheNum
derari
Posts: 17
Joined: February 24th, 2011, 5:39 pm

Re: String to number from RunCommand

Post by derari »

Thanks! I tried a calc measure with "measureL2Cache + 0" but that used the RunCommand's result code. There should be a wiki for Frequently Occurring Problems.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: String to number from RunCommand

Post by balala »

derari wrote: December 18th, 2018, 12:54 pm There should be a wiki for Frequently Occurring Problems.
Yes, there is: this forum.
Did it work?
derari
Posts: 17
Joined: February 24th, 2011, 5:39 pm

Re: String to number from RunCommand

Post by derari »

Yes, your solution fixed it. Thanks again!
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: String to number from RunCommand

Post by balala »

You're welcome.