I'm working currency conversion into one of my apps and figured I'd share a free way to convert between currencies using live data from Google. Credit is due to oohyeah's Blog (google search it, I can't post links to domains/pages). Hopefully it saves someone a few minutes on their apps.
Code: Select all
function convertCurrency amount, startCur, endCur
   -- Cleanup input values before assembling the URL --
   put urlEncode(amount) into amount
   put urlEncode(startCur) into startCur -- USD, EUR, AUD, etc.
   put urlEncode(endCur) into endCur
   
   -- Create our URL to retrieve the data from Google --
   put "hl=en&q=" & amount & startCur & "%3D%3F" & endCur into theURL
   put "http://google.com/ig/calculator?" & theURL into theURL
   get url theURL
   
   -- The data comes back in JSON format. Below isn't elegant, but gets the job done
    -- To see what's going on here, I'd recommend you look at split and the raw data of the URL call
   split it using quote 
   split it[4] using space
   return it[4][1]
end convertCurrencyBrent Anderson

 I don't want to get into the fact that they correctly convert negative numbers.
 I don't want to get into the fact that they correctly convert negative numbers. 