yamato wrote: ↑June 7th, 2021, 8:41 pm
Hi all
Newby here
I need to use a string as a number,
however it doesn't work, because the format of the string is such as : 1,234.5 (with a coma)
I already tried :
that works well to get rid of the coma, but the result (1234.5) oddly doesn't seems to be usable as a number, or when I use it as a number, that number is 1 (not 1234.5).
What's going wrong ?
yamato
The key is that you must use the "string" value of the measure containing the numeric value, so the Substitute is applied where the value is used. Substitute is only applied to the string value of a measure, and only at the time and place where the string value is "used".
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
MyNum=1,234.5
[MeasureString]
Measure=String
String=#MyNum#
Substitute=",":""
[MeasureNumber]
Measure=Calc
Formula=([MeasureString] + 765.5)
DynamicVariables=1
[MeterNumber]
Meter=String
MeasureName=MeasureNumber
FontSize=13
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
NumOfDecimals=1
AntiAlias=1
The important bit here is that I am using the [MeasureString] section variable to get the value. That will force the Calc measure to use the string value of the measure, and it will then convert it to a number if the result is in fact numeric. Note that if I just used
Formula=MeasureString + 765.5, that would attempt to use the number value of the measure, without any Substitute applied, and the value would be "1", which is where it will stop trying to convert it to a number, since a
, comma is not a valid part of a numeric value.
So the answer would be 766.5, which is the 1 added to the 765.5
https://docs.rainmeter.net/manual/variables/section-variables/#MeasureParameters
1.jpg
You do not have the required permissions to view the files attached to this post.