Using Exchange Rates

Hello

Am wondering if anyone knows of a way to get Servoy to update exchange rates via the web. I’ve done a search of the forum and found this link:

http://forum.servoy.com/viewtopic.php?t … t=currency

But, being relatively new to Servoy, I have no idea how to go about executing this within my solution.

If anyone has any pointers it would be much appreciated

Thanks

Chris

I’ll take a crack at that. To get the rate for USD, for example, you’d do something like:

var foo=plugins.http.getPageData('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
var bar=foo.match(/\n\W+<Cube currency=\'USD\'\W+rate=\'([0-9\.]+)\'\/>\n/);
application.output(bar[1]);

and likewise for other currencies. The tricky bit is the regular expression in line 2. It will be well worth your time to learn RegEx syntax thoroughly; there are lots of good tutorials on the web, perhaps someone has a favorite.

Good luck.

My favorite is an oReilly pocket on regular expression. VERY helpful. It is always on or next to my desk…