It is currently March 28th, 2024, 6:11 pm

[Help] Converting Currency

Get help with creating, editing & fixing problems with skins
Post Reply
keneseuu
Posts: 1
Joined: December 27th, 2017, 3:11 am

[Help] Converting Currency

Post by keneseuu »

I'm modifying this skin to monitor live bitcoin rate with USD to PHP conversion.
Credits to 2W2L2R2D for the original version (USD only without the conversion).

Problem:
- Can't calculate conversion rate from USD to PHP, when I'm getting the value of USD, only the number before the comma is getting (e.g. 15,750. The number 15 is getting fetched, not 15750)

I've tried:
- Removing the comma by using Substitute but still the same problem occurs.

Example Current Output:
$15,750 = P751 (because current rate is $1 = P50.099, thus 15 * 50.099 = 751)

Expected Output
$15,750 = P789,059

Code: Select all

[Rainmeter]
Update=10
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=simple BTC price ticker
Author=2W2L2R2D
Version=0.3
License=
Information=A simple text bitcoin price ticker using the Coindesk API. Only USD support yet... GBP & EUR implementation doesn't seem hard, if I have some time I'll do it later. If you like it send some love to 1762Xnc7gw4Qd4yCsLnoifCqufnqCL88b8

[Variables]
Currency=USD
;not implemented yet

[MeasureParent]
Measure=Plugin
Plugin=WebParser
URL=http://api.coindesk.com/v1/bpi/currentprice.json
RegExp=rate":"(......) 
;play with this regex to manually change to other currency

[MeasureParent1]
Measure=Plugin
Plugin=WebParser
URL=https://api.fixer.io/latest?base=USD&symbols=USD,PHP
RegExp=rates":{"PHP":(......) 
; PHP to USD conversion

[MeasureChild1]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasureChild2]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent1]
StringIndex=1

; MeasureOne is for testing to calculate peso to usd (bitcoin = usd)
[MeasureOne]
Measure=Calc
Formula=MeasureChild1 * MeasureChild2
DynamicVariables=1

[MeterChild1]
Meter=String
MeasureName=MeasureChild1
MeasureName2=MeasureOne
X=295
Y=0r
W=280
H=32
FontSize=24
FontColor=255,255,255,128
SolidColor=0,0,0,1
Padding=0,0,0,0
StringAlign=Right
AntiAlias=1
Text=$%1 = P%2
Hope you can help me fix the problem!

EDIT: Looks like I've fixed it myself. lol

Code: Select all

[Rainmeter]
Update=10
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=simple BTC price ticker
Author=2W2L2R2D
Version=0.3
License=
Information=A simple text bitcoin price ticker using the Coindesk API. Only USD support yet... GBP & EUR implementation doesn't seem hard, if I have some time I'll do it later. If you like it send some love to 1762Xnc7gw4Qd4yCsLnoifCqufnqCL88b8

[Variables]
Currency=USD
;not implemented yet

[MeasureParent]
Measure=Plugin
Plugin=WebParser
URL=http://api.coindesk.com/v1/bpi/currentprice.json
RegExp=rate":"(......) 
; Get current USD to BTC rate

[MeasureParent1]
Measure=Plugin
Plugin=WebParser
URL=https://api.fixer.io/latest?base=USD&symbols=USD,PHP
RegExp=rates":{"PHP":(......) 
; PHP to USD conversion

[MeasureChild1]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1
Substitute=",":""

[MeasureChild2]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent1]
StringIndex=1
Substitute=",":""

[MeasureOne]
Measure=Calc
Formula=[MeasureChild1] * [MeasureChild2]
DynamicVariables=1
; Calculate USD to PHP

[MeasureUSD]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasurePHP]
Measure=Calc
Formula=MeasureOne
RegExpSubstitute=1
Substitute="^(\d{1,2}?)((\d{3})+)$":"\1,\2","(\d{3})(?=\d)":"\1,"

[MeterChild1]
Meter=String
MeasureName=MeasureUSD
MeasureName2=MeasurePHP
X=295
Y=0r
W=280
H=32
FontSize=24
FontColor=255,255,255,128
SolidColor=0,0,0,1
Padding=0,0,0,0
StringAlign=Right
AntiAlias=1
Text=$%1 = P%2
Post Reply