It is currently June 16th, 2021, 11:31 am

How can I convert a string to a number?

Help with creating, editing & fixing problems with skins
jav26122
Posts: 26
Joined: February 9th, 2015, 8:45 pm

How can I convert a string to a number?

Post by jav26122 »

I have a measure that gives a string, but I need to be able to have it be a number. Seems like it should be a pretty easy thing to do but I can't find anything about how to do that.
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How can I convert a string to a number?

Post by jsmorley »

Strictly speaking you don't need to. If a string value in Rainmeter is "numeric", then any Calc measure or formula will use it as a number.

[MeasureString]
Measure=String
String=3

[MeasureCalc]
Measure=Calc
Formula=MeasureString + 2

MeasureCalc will have a value of 5.

All Rainmeter measures return both a "string" and "number" value. For numeric measures, like FreeDiskSpace or Calc, the "string" value will just be a string representation of the number. For string-based measures, like String or WebParser, the "number" value will be a number if the string is purely "numeric" like "3" or "13036.287", or zero if it isn't like "The number is 3".

I'd need to know more about specifically what is giving you trouble.
jav26122
Posts: 26
Joined: February 9th, 2015, 8:45 pm

Re: How can I convert a string to a number?

Post by jav26122 »

Yeah well I'm trying to convert my old string off of using GPU-Z and use hwinfo like you said yesterday... This is what I have so far and it's not doing anything.

Code: Select all

[Rainmeter]
Background=..\Images\bg_ram_cpu.png
Update=1000

[Variables]

@Include=#@#\HWiNFO.inc
@Include="..\UserVariables.inc"

; ----------------------------------

[GPUMaxLoad]
Measure=Calc
MaxValue=100
MinValue=0
Formula=100

[MeasureGPULoad]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=#HWiNFO-GPU0-SensorId#
HWiNFOSensorInstance=#HWiNFO-GPU0-SensorInstance#
HWiNFOEntryId=#HWiNFO-GPU0-Usage#
HWiNFOType=CurrentValue
MinValue=0
MaxValue=100


[GPU]
MeasureName=MeasureGPULoad
Meter=ROUNDLINE
X=0
Y=0r
W=108
H=87
LineWidth=5
StartAngle=4.71238898
RotationAngle=6.28318531
LineLength=31
LineStart=36
LineColor=#LineColor1#
Solid=1
AntiAlias=10

[MaxLoad]
MeasureName=GPUMaxLoad
Meter=ROUNDLINE
X=0
Y=0r
W=108
H=87
LineWidth=5
StartAngle=4.71238898
RotationAngle=6.28318531
LineLength=31
LineStart=36
LineColor=#LineColor2#
Solid=1
AntiAlias=10
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How can I convert a string to a number?

Post by jsmorley »

What "string" are you talking about?

Also, are you SURE you mean this?

@Include="..\UserVariables.inc"

The parent folder above your skin folder?
jav26122
Posts: 26
Joined: February 9th, 2015, 8:45 pm

Re: How can I convert a string to a number?

Post by jav26122 »

I was looking off of the original hwinfo example and saw that it displayed the information in strings like

Code: Select all

[MeterHWiNFOGPU0UsageValue]
Meter=String
MeasureName=HWiNFOGPU0Usage
X=1R
Y=0r
Text="%1%"
NumOfDecimals=2
MeterStyle=HWiNFOTextStyle
FontColor=#HWiNFOColor1#
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How can I convert a string to a number?

Post by jsmorley »

So what isn't working?
jav26122
Posts: 26
Joined: February 9th, 2015, 8:45 pm

Re: How can I convert a string to a number?

Post by jav26122 »

Well I found out that @Include=#@#\HWiNFO.inc is causing the issue. Are you not allowed to have more than one @Include? I don't know much about making skins.
jav26122
Posts: 26
Joined: February 9th, 2015, 8:45 pm

Re: How can I convert a string to a number?

Post by jav26122 »

Got it...just had to name them differently.
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How can I convert a string to a number?

Post by jsmorley »

jav26122 wrote:Well I found out that @Include=#@#\HWiNFO.inc is causing the issue. Are you not allowed to have more than one @Include? I don't know much about making skins.
You are not allowed to have more than one of ANY Key in Key=Value in a single [Section] of a .ini file.

However, you can use:

@Include=#@#SomeFile.inc
@Include2=#@#SomeOtherFile.inc
User avatar
jsmorley
Developer
Posts: 21758
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How can I convert a string to a number?

Post by jsmorley »

BTW, in your skin, you have what looks to be a "background" Roundline meter coming after (in the skin .ini I mean) what looks to be the Roundline meter that is displaying the value. That will mean that the measured value will be "behind" the background meter, and will never show, assuming the background is not at least partially transparent.

I suspect you want to reverse those. The "Z-position" or "front to back position" of meters in Rainmeter is entirely based on the order they are in the skin. Things "after" are on top of things "before" in the .ini when they share a position in the X / Y plane.

Also, just as a hint, any Roundline meter that has NO MeasureName=SomeMeasure on it will assume the value is 100%, so there is no need to create some dummy Calc measure who's only job it is is to return a value of 100%. A background RoundLine meter can just be exactly the same values as the "real" one, just setting no MeasureName and using a different color.