/* --------------------------------------------------------------- */ /* pound -- get exchange rates for GBP from European Central Bank. */ /* --------------------------------------------------------------- */ /* */ /* Copyright (c) Mike Cowlishaw, 2012. All rights reserved. */ /* */ /* Permission to use, copy, modify, and/or distribute this */ /* software for any purpose with or without fee is hereby granted, */ /* provided that the above copyright notice and this permission */ /* notice appear in all copies, and that notice and the date of */ /* any modifications be added to the software. */ /* */ /* This software is provided "as is". No warranties, whether */ /* express, implied, or statutory, including, but not limited to, */ /* implied warranties of merchantability and fitness for a */ /* particular purpose apply to this software. The author shall */ /* not, in any circumstances, be liable for special, incidental, */ /* or consequential damages, for any reason whatsoever. */ /* */ /* --------------------------------------------------------------- */ /* When called (as a command, function, or subroutine) this lists */ /* the exchange rates for one pound sterling for various major */ /* and European currencies. */ /* */ /* Currencies must be listed at the URL initialized below. */ /* */ /* Requires geturl.rex */ /* --------------------------------------------------------------- */ /* 2012.05.22 Initial version. */ /* 2012.11.01 Make more easily alterable */ /* 2013.08.21 New URL for ECB */ signal on novalue erase=1 -- 0 to keep body file cur='GBP' -- currency to report -- url='http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml' -- Moved 2013.08 to: url='http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml' say 'Getting latest European Central Bank rates ...' file='gotbody.$$$' body=geturl(url) if length(body)<3 then do say '[Empty response -- cannot report rates.]' exit end call charout file, body call charout file /* Should now have an XML file of key rates for Euro; read all */ /* of them and then calculate the rate requested. */ date='' rate.='?' rate.eur=1.0000 count=1 list.count='EUR 1.0000' do while lines(file)>0 line=linein(file) -- quotes might be single or double line=changestr('''', line, '"') parse var line 'nul' call sysfiledelete file -- set up nice names array name.='?' name.AUD='Australia Dollar' name.BGN='Bulgaria Lev' name.BRL='Brazil Real' name.CAD='Canada Dollar' name.CHF='Switzerland Franc' name.CNY='China Yuan Renminbi' name.CZK='Czech Republic Koruna' name.DKK='Denmark Krone' name.EUR='Euro' name.GBP='UK Pound' name.HKD='Hong Kong Dollar' name.HRK='Croatia Kuna' name.HUF='Hungary Forint' name.IDR='Indonesia Rupiah' name.ILS='Israel Shekel' name.INR='India Rupee' name.JPY='Japan Yen' name.KRW='Korea (South) Won' name.LTL='Lithuania Litas' name.LVL='Latvia Lat' name.MXN='Mexico Peso' name.MYR='Malaysia Ringgit' name.NOK='Norway Krone' name.NZD='New Zealand Dollar' name.PHP='Philippines Peso' name.PLN='Poland Zloty' name.RON='Romania New Leu' name.RUB='Russia Ruble' name.SEK='Sweden Krona' name.SGD='Singapore Dollar' name.THB='Thailand Baht' name.TRY='Turkey Lira' name.USD='United States Dollar' name.ZAR='South Africa Rand' say say 'One' name.cur '('cur') buys ['date']:' say list.0=count call sysstemsort 'list.', 'A', 'I', 1 f=rate.cur do i=1 to count parse var list.i c t r=t/f r=format(r,,2) say right(r,9) c name.c end say