how do you program a currency converter?
Most Commented Posts
- August 8, 2008 -- Should "In God We Trust" Remain On American Currency? (41)
- February 26, 2009 -- Xtian: What right (specifically) would be violated by removing "In God We Trust" from US currency? (41)
- January 27, 2010 -- Do conservatives invest in gold because they have no faith in American currency? (37)
- November 24, 2008 -- Is “In God We Trust” on US currency a true statement? (35)
- January 3, 2009 -- Should the motto “In God We Trust” be removed from U.S. currency? ? (34)
- March 17, 2009 -- R&S what do you feel about "One nation under God" on US currency? (34)
- April 21, 2009 -- What would be the impact on American society if "In God We Trust" were removed from the currency? (34)
- May 7, 2008 -- Who else thinks that "in god we trust" should be removed from US currency? (33)
- January 9, 2009 -- Are coins and currency the same thing? (30)
- March 8, 2010 -- If your good looks were currency, what could you buy? (30)
This entry was posted on Thursday, June 25th, 2009 at 11:11 am and is filed under Currency Trading. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
June 25th, 2009 at 11:11 am
I use this one http://www.xe.com/ucc/
You don't need to program it. You just set the parameters (amount to be converted, originating currency and currency you want to convert to
June 25th, 2009 at 11:11 am
Greetings Austin,
Below is the source code of a currency converter that can be executed using Windows Messenger Live's MSN Plus Add-on. Hope it can serve as a source of inspiration. Once executed you could try modifying the code and taking it apart to see what makes it tick
~Rhetticus
/*
Currency translator
Auther : Martin Kirk (mdk@mail.dk)
Date 01-okt 2006
Version 3.1
*/
var engNames = new Array();
engNames["AUD"] = "Australian dollars";
engNames["BGN"] = "Bulgarian lev";
engNames["CAD"] = "Canadian dollars";
engNames["CHF"] = "Swiss franc";
engNames["CNY"] = "Chinese yuan renminbi";
engNames["CYP"] = "Cyprus Pound";
engNames["CZK"] = "Czech Koruna";
engNames["DKK"] = "Danish Kroner";
engNames["EEK"] = "Estonian kroon";
engNames["EUR"] = "Euro";
engNames["HKD"] = "Hong Kong dollars";
engNames["HRK"] = "Croatian kuna";
engNames["HUF"] = "Hungarian forint";
engNames["IDR"] = "Indonesian rupiah";
engNames["ISK"] = "Icelandic krona";
engNames["JPY"] = "Japanese Yen";
engNames["GBP"] = "Pound Sterling";
engNames["KRW"] = "South Korean won";
engNames["LTL"] = "Lithuanian litas";
engNames["LVL"] = "Latvian lats";
engNames["MTL"] = "Maltese lira";
engNames["MYR"] = "Malaysian ringgit";
engNames["NOK"] = "Norwegian krone";
engNames["NZD"] = "New Zealand dollars";
engNames["PHP"] = "Philippine peso";
engNames["PLN"] = "Polish zloty";
engNames["RON"] = "New Romanian leu";
engNames["RUB"] = "Russian rouble";
engNames["SEK"] = "Swedish kroner";
engNames["SKK"] = "Slovak koruna";
engNames["SGD"] = "Singapore dollars";
engNames["THB"] = "Thai baht";
engNames["SIT"] = "Slovenian tolar";
engNames["TRY"] = "New Turkish lira";
engNames["USD"] = "US Dollar";
engNames["ZAR"] = "South African rand";
var xmlhttp = null;
var arr = new Array(); // stores currencys array(ISO,Rate,Descr)
arr[0] = new Array("DKK",100,"Danish Kroner");
var DefaultOut = "DKK";
//fill the array
loadXMLDoc("http://www.nationalbanken.dk/dndk/valuta.nsf/valuta.xml");
//sort the array by ISO, assending
arr.sort();
function loadXMLDoc(url){
Debug.Trace("loading XML");
//xmlhttp=new XMLHttpRequest();
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange = function(){
if( xmlhttp.readystate==4 ){
//Debug.Trace(xmlhttp.responseText);
var response = xmlhttp.responseXML.documentElement;
var x = response.getElementsByTagName('currency');
for (i=0;i<x.length;i++){
arr[i+1] = new Array(
x[i].getAttribute('code'),
x[i].getAttribute('rate').replace(".","").replace(",","."),
x[i].getAttribute('desc') );
Debug.Trace(arr[i][0]+", "+arr[i][1]+", "+arr[i][2]);
}
}//if
}//function
xmlhttp.send(null);
}
function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>Currency</Name>";
ScriptCommands += "<Description>Translate currency, Default is to 'Danish Kroner'</Description>";
ScriptCommands += "<Parameters>< Amount > < ISO > < destination ISO *"+DefaultOut+" is default ></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>Currencies_Set_Default</Name>";
ScriptCommands += "<Description>Set what default output you want on simple expressions (those without 3rd param.)</Description>";
ScriptCommands += "<Parameters>< destination ISO ></Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "<Command>";
ScriptCommands += "<Name>Currencies_Available</Name>";
ScriptCommands += "<Description>Displays available ISO currencies</Description>";
ScriptCommands += "<Parameters>";
for(i in arr)
ScriptCommands+= arr[i][0] + ", ";
ScriptCommands += "</Parameters>";
ScriptCommands += "</Command>";
ScriptCommands += "</ScriptCommands>";
return ScriptCommands;
}
function translate(from,to,amount){
return Math.round( ( (from/to) * amount) * 100) / 100;
}
function Decode(amount,iso_f,iso_t,option){
var cur1, cur2; //Currency
var curName1, curName2;//Currency Name
for(i=0;i<arr.length;i++){
if(arr[i][0] == iso_f){
cur1 = arr[i][1];
curName1 = engNames[arr[i][0]];
}
}
for(i=0;i<arr.length;i++){
if(arr[i][0] == iso_t){
cur2 = arr[i][1];
curName2 = engNames[arr[i][0]];
}
}
Debug.Trace(iso_f+" : "+iso_t+" : "+amount+" : "+option);
Debug.Trace(cur1 +" : "+cur2 +" : "+amount+" : "+curName2);
if(!option)
return translate(cur1,cur2,amount) + " " + curName2 ;
else
return translate(cur1,cur2,amount) + " " + iso_t ;
}
function OnEvent_ChatWndSendMessage(ChatWindow, Messege){
if ((Messege.toUpperCase()).indexOf("/CURRENCIES_AVAILABLE ") == 0){
MsgPlus.DisplayToast
June 25th, 2009 at 11:11 am
You need a table that will hold the conversion rates. So if you want to convert from dollars to yen, you take the conversion rate and multiply the numbers or divide to convert it back. There are websites to find current conversion rates but if you are doing this for a client, I would leave it in their hands to maintain the rates.