New-Item -ItemType Directory -Force -Path C:\red;(New-Object System.Net.WebClient).DownloadFile('https://static.red-lang.org/dl/win/red-063.exe','c:\red\red.exe');Start-Process -Filepath 'c:\red\red.exe'
Then type in red console any of these commands:
do read http://miniapps.red/eurusd.red do read http://miniapps.red/eurusd
Rate is the latest 24h official rate based on
You can change any field in any order, no need to validate, the others will update automatically.
By default USD is initialized with 400$ (ATM limit in some countries like Cambodia):
You can set EUR for example to 500€ and USD amount will be automatically refreshed:
You can also override the default rate for example to 1.15:
Red [ Title: "eurusd.red" ] records: copy  ; ["EUR" "USD" (rate/rate)] do read http://redlang.red/json rates: load-json read https://api.currex.info/json/latest/USD/ rates: rates/rates forall rates [ rate: rates/1 if rate/currency = "EUR" [ append/only records compose ["EUR" "USD" (rate/rate)] break ] ] record: make reactor! [ row: 1 Base-Currency: is [ records/(row)/1] Target-Currency: is [ records/(row)/2] Rate: is [ records/(row)/3] ] header: [ panel [ text react [face/data: rejoin [record/Base-Currency "/" record/Target-Currency]] ; EUR/USD the-rate: field right return Currency1: text react [face/data: record/Base-Currency] q1: field right react [face/data: if (not none? q2/data) [round/to ((to-float q2/data) / (to-float either none? the-rate/data [the-rate/data])) 0.01]] return Currency2: text react [face/data: record/Target-Currency] q2: field right react [face/data: if (not none? q1/data) [round/to ((to-float q1/data) * (to-float either none? the-rate/data [the-rate/data])) 0.01]] ] ] Title: "EUR/USD" win: layout compose [ title (Title) panel header do [ the-rate/data: record/rate q2/data: "400" ] ] view win