It is currently November 29th, 2021, 6:18 am

## Decimal...

Help with creating, editing & fixing problems with skins
maxmax00
Posts: 3
Joined: April 24th, 2010, 8:12 pm

### Decimal...

Hi, my input from WebParser.dll it could be for exsample: 6,88 or 5,746

I need to calculate a formula with this numbers... Comma is the first problem, I cant do formulas with that strings because it will cut the decimal. (I have tried with Substitute=",":"." but didnt work)

so i turn my RegExp line in something like this: RegExp="<***********>(.*),(.*)<****>" but even in this case i cant do Formula=Measure2/1000+Measure1
because :

case 1: 5,746 = 5.746 OK
case 2: 6,88 = 6.088 WRONG

what can i do?

ps: sorry for my english jsmorley
Developer
Posts: 22414
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: Decimal...

I really think it is looking for the UK / US method for the decimal places and thousands grouping indicators.

1,200 = One Thousand Two Hundred
12.89 = Twelve point Eight Nine

If I have a text file:

test.txt

And in it put
<1>123.98</1>

Then:

Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1

[MeasureDivide]
Measure=Calc

[MeterNumber]
Meter=String
MeasureName2=MeasureDivide
NumOfDecimals=4
FontSize=20
FontColor=255,255,255,255
Text = %1 | %2

Works fine, and displays 123.98 | 1.2398

If however, I have in test.txt:

<1>123,98</1>

Then the same .ini code above returns 123,98 | 1.2300

Which is just 123 / 100 as it is ignoring everything after the comma, which it just doesn't understand to be a decimal place indicator.

Not sure what the right answer is here. Maybe Kenz0 or Alex can jump in. Putting a Substitute=",":"." on the WebParser measure doesn't help, as substitutions are purely cosmetic and are not done when you use the result in a "Calc". However there must be come clever way to get around this limitation that Calc doesn't seem to like "," as decimals and "." as thousands separators, which is standard in many countries outside of the US and UK. Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am

### Re: Decimal...

The substitute will work, but you need to change how you use the measure in the formula. Instead of using just the measure name, encase it in square brackets and then add the line DynamicVariables=1. This way, the substitute will go through, replacing the "," with a "." like so:

Code: Select all

``````[ExampleCalc]
Measure=Calc
Formula=[SomeMeasure]
DynamicVariables=1
`````` jsmorley
Developer
Posts: 22414
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: Decimal...

Thanks Alex. I completely forgot about that.

A fuller explanation is here: http://rainmeter.net/cms/Tips-SubValuesInCalc
maxmax00
Posts: 3
Joined: April 24th, 2010, 8:12 pm

### Re: Decimal...

Code: Select all

``````[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1

[MeasureDivide]
Measure=Calc
DynamicVariables=1

[MeterNumber]
Meter=String
MeasureName2=MeasureDivide
MeasureName3=GetSubstitutedValue
NumOfDecimals=4
FontSize=10
FontColor=255,255,255,255
Text = %1 | %2 | %3

[InitialValue]
Measure=Calc

[GetSubstitutedValue]
Measure=Calc
Formula=[InitialValue]/100
DynamicVariables=1``````
the output still the same... 12,34 | 0.01200 | 0.01200 jsmorley
Developer
Posts: 22414
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: Decimal...

Code: Select all

``````[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
Substitute=",":"."
StringIndex=1

[MeasureDivide]
Measure=Calc
DynamicVariables=1

[MeterNumber]
Meter=String
MeasureName2=MeasureDivide
NumOfDecimals=4
FontSize=10
FontColor=255,255,255,255
Text = %1 | %2
``````
You still need the substitution, you didn't have one in your version of my code. So you do the substitution on the WebParser measure as you would if you were just displaying the results, then use the value returned in square brackets [MeasureLink] in a calc with DynamicVariables=1 and it will get the 123.98 in the calc instead of 123,98. Now you can use THAT value any way you want.

123.98 | 1.2398
maxmax00
Posts: 3
Joined: April 24th, 2010, 8:12 pm

### Re: Decimal...

lol right i forgot the Substitute :facepalm:

thank you soo much ^_^ jsmorley
Developer
Posts: 22414
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: Decimal...

No problem. By the way, if you want to "calculate" using the period (which you must) but still "display" the original value with the comma, do it like this:

Code: Select all

``````[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1

Measure=Plugin
Plugin=Plugins\WebParser.dll
Substitute=",":"."
StringIndex=1

[MeasureDivide]
Measure=Calc