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
It is currently April 20th, 2024, 2:15 pm
Decimal...
-
- Posts: 3
- Joined: April 24th, 2010, 8:12 pm
-
- Developer
- Posts: 22629
- 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:
[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1
[MeasureDivide]
Measure=Calc
Formula=(MeasureLink / 100)
[MeterNumber]
Meter=String
MeasureName=MeasureLink
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.
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:
[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1
[MeasureDivide]
Measure=Calc
Formula=(MeasureLink / 100)
[MeterNumber]
Meter=String
MeasureName=MeasureLink
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.
-
- Rainmeter Sage
- Posts: 642
- Joined: July 19th, 2009, 5:59 am
- Location: Montreal, QC, Canada
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
-
- Developer
- Posts: 22629
- 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
A fuller explanation is here: http://rainmeter.net/cms/Tips-SubValuesInCalc
-
- 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
Formula=(MeasureLink / 100)
DynamicVariables=1
[MeterNumber]
Meter=String
MeasureName=MeasureLink
MeasureName2=MeasureDivide
MeasureName3=GetSubstitutedValue
NumOfDecimals=4
FontSize=10
FontColor=255,255,255,255
Text = %1 | %2 | %3
[InitialValue]
Measure=Calc
Formula=MeasureLink
[GetSubstitutedValue]
Measure=Calc
Formula=[InitialValue]/100
DynamicVariables=1
12,34 | 0.01200 | 0.01200
-
- Developer
- Posts: 22629
- 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
Formula=([MeasureLink] / 100)
DynamicVariables=1
[MeterNumber]
Meter=String
MeasureName=MeasureLink
MeasureName2=MeasureDivide
NumOfDecimals=4
FontSize=10
FontColor=255,255,255,255
Text = %1 | %2
123.98 | 1.2398
-
- Posts: 3
- Joined: April 24th, 2010, 8:12 pm
Re: Decimal...
lol right i forgot the Substitute :facepalm:
thank you soo much ^_^
thank you soo much ^_^
-
- Developer
- Posts: 22629
- 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:
123,98 | 123.98 | 1.2398
Code: Select all
[MeasureLink]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#test.txt
RegExp="(?siU)<1>(.*)</1>"
StringIndex=1
[MeasureLinkSubstituted]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureLink]
Substitute=",":"."
StringIndex=1
[MeasureDivide]
Measure=Calc
Formula=([MeasureLinkSubstituted] / 100)
DynamicVariables=1
[MeterNumber]
Meter=String
MeasureName=MeasureLink
MeasureName2=MeasureLinkSubstituted
MeasureName3=MeasureDivide
NumOfDecimals=4
FontSize=10
FontColor=255,255,255,255
Text = %1 | %2 | %3