Alpha Video Training
Results 1 to 18 of 18

Thread: Currency Conversion Function

  1. #1

    Default Currency Conversion Function

    Here is a quick simple function that looks up the exchange rate for two currencies and returns the values.

    Enjoy...keep the ideas flowing :-)

    Code:
    'Date Created: 28-Jan-2008 04:02:17 AM
    'Last Updated: 28-Jan-2008 04:02:17 AM
    'Created By  : Mr. GreenJeans
    'Updated By  : Mr. GreenJeans
    FUNCTION curr_con AS a ( )
        
        'Create an XDialog dialog box to prompt for parameters.
    DIM SHARED From as C
    DIM SHARED to as C
    DIM SHARED Amount as N
    DIM SHARED varC_result as C
    Amount = 0.00
    DELETE a_From        
    DIM a_From[151] as c
    dim temp_list as c 
    temp_list = <<%list%
    AFA-Afghanistan Afghani
    ALL-Albanian Lek
    DZD-Algerian Dinar
    ARS-Argentine Peso
    AWG-Aruba Florin
    AUD-Australian Dollar
    BSD-Bahamian Dollar
    BHD-Bahraini Dinar
    BDT-Bangladesh Taka
    BBD-Barbados Dollar
    BZD-Belize Dollar
    BMD-Bermuda Dollar
    BTN-Bhutan Ngultrum
    BOB-Bolivian Boliviano
    BWP-Botswana Pula
    BRL-Brazilian Real
    GBP-British Pound
    BND-Brunei Dollar
    BIF-Burundi Franc
    XOF-CFA Franc (BCEAO)
    XAF-CFA Franc (BEAC)
    KHR-Cambodia Riel
    CAD-Canadian Dollar
    CVE-Cape Verde Escudo
    KYD-Cayman Islands Dollar
    CLP-Chilean Peso
    CNY-Chinese Yuan
    COP-Colombian Peso
    KMF-Comoros Franc
    CRC-Costa Rica Colon
    HRK-Croatian Kuna
    CUP-Cuban Peso
    CYP-Cyprus Pound
    CZK-Czech Koruna
    DKK-Danish Krone
    DJF-Dijibouti Franc
    DOP-Dominican Peso
    XCD-East Caribbean Dollar
    EGP-Egyptian Pound
    SVC-El Salvador Colon
    EEK-Estonian Kroon
    ETB-Ethiopian Birr
    EUR-Euro
    FKP-Falkland Islands Pound
    GMD-Gambian Dalasi
    GHC-Ghanian Cedi
    GIP-Gibraltar Pound
    XAU-Gold Ounces
    GTQ-Guatemala Quetzal
    GNF-Guinea Franc
    GYD-Guyana Dollar
    HTG-Haiti Gourde
    HNL-Honduras Lempira
    HKD-Hong Kong Dollar
    HUF-Hungarian Forint
    ISK-Iceland Krona
    INR-Indian Rupee
    IDR-Indonesian Rupiah
    IQD-Iraqi Dinar
    ILS-Israeli Shekel
    JMD-Jamaican Dollar
    JPY-Japanese Yen
    JOD-Jordanian Dinar
    KZT-Kazakhstan Tenge
    KES-Kenyan Shilling
    KRW-Korean Won
    KWD-Kuwaiti Dinar
    LAK-Lao Kip
    LVL-Latvian Lat
    LBP-Lebanese Pound
    LSL-Lesotho Loti
    LRD-Liberian Dollar
    LYD-Libyan Dinar
    LTL-Lithuanian Lita
    MOP-Macau Pataca
    MKD-Macedonian Denar
    MGF-Malagasy Franc
    MWK-Malawi Kwacha
    MYR-Malaysian Ringgit
    MVR-Maldives Rufiyaa
    MTL-Maltese Lira
    MRO-Mauritania Ougulya
    MUR-Mauritius Rupee
    MXN-Mexican Peso
    MDL-Moldovan Leu
    MNT-Mongolian Tugrik
    MAD-Moroccan Dirham
    MZM-Mozambique Metical
    MMK-Myanmar Kyat
    NAD-Namibian Dollar
    NPR-Nepalese Rupee
    ANG-Neth Antilles Guilder
    NZD-New Zealand Dollar
    NIO-Nicaragua Cordoba
    NGN-Nigerian Naira
    KPW-North Korean Won
    NOK-Norwegian Krone
    OMR-Omani Rial
    XPF-Pacific Franc
    PKR-Pakistani Rupee
    XPD-Palladium Ounces
    PAB-Panama Balboa
    PGK-Papua New Guinea Kina
    PYG-Paraguayan Guarani
    PEN-Peruvian Nuevo Sol
    PHP-Philippine Peso
    XPT-Platinum Ounces
    PLN-Polish Zloty
    QAR-Qatar Rial
    ROL-Romanian Leu
    RUB-Russian Rouble
    WST-Samoa Tala
    STD-Sao Tome Dobra
    SAR-Saudi Arabian Riyal
    SCR-Seychelles Rupee
    SLL-Sierra Leone Leone
    XAG-Silver Ounces
    SGD-Singapore Dollar
    SKK-Slovak Koruna
    SIT-Slovenian Tolar
    SBD-Solomon Islands Dollar
    SOS-Somali Shilling
    ZAR-South African Rand
    LKR-Sri Lanka Rupee
    SHP-St Helena Pound
    SDD-Sudanese Dinar
    SRG-Surinam Guilder
    SZL-Swaziland Lilageni
    SEK-Swedish Krona
    TRY-Turkey Lira
    CHF-Swiss Franc
    SYP-Syrian Pound
    TWD-Taiwan Dollar
    TZS-Tanzanian Shilling
    THB-Thai Baht
    TOP-Tonga Pa'anga
    TTD-Trinidad&amp;Tobago Dollar
    TND-Tunisian Dinar
    TRL-Turkish Lira
    USD-U.S. Dollar
    AED-UAE Dirham
    UGX-Ugandan Shilling
    UAH-Ukraine Hryvnia
    UYU-Uruguayan New Peso
    VUV-Vanuatu Vatu
    VEB-Venezuelan Bolivar
    VND-Vietnam Dong
    YER-Yemen Riyal
    YUM-Yugoslav Dinar
    ZMK-Zambian Kwacha
    ZWD-Zimbabwe Dollar
    %list%
    
    a_From.initialize(temp_list)
    
    DELETE a_to        
    DIM a_to[151] as c
    dim temp_list as c 
    temp_list = <<%list%
    AFA-Afghanistan Afghani
    ALL-Albanian Lek
    DZD-Algerian Dinar
    ARS-Argentine Peso
    AWG-Aruba Florin
    AUD-Australian Dollar
    BSD-Bahamian Dollar
    BHD-Bahraini Dinar
    BDT-Bangladesh Taka
    BBD-Barbados Dollar
    BZD-Belize Dollar
    BMD-Bermuda Dollar
    BTN-Bhutan Ngultrum
    BOB-Bolivian Boliviano
    BWP-Botswana Pula
    BRL-Brazilian Real
    GBP-British Pound
    BND-Brunei Dollar
    BIF-Burundi Franc
    XOF-CFA Franc (BCEAO)
    XAF-CFA Franc (BEAC)
    KHR-Cambodia Riel
    CAD-Canadian Dollar
    CVE-Cape Verde Escudo
    KYD-Cayman Islands Dollar
    CLP-Chilean Peso
    CNY-Chinese Yuan
    COP-Colombian Peso
    KMF-Comoros Franc
    CRC-Costa Rica Colon
    HRK-Croatian Kuna
    CUP-Cuban Peso
    CYP-Cyprus Pound
    CZK-Czech Koruna
    DKK-Danish Krone
    DJF-Dijibouti Franc
    DOP-Dominican Peso
    XCD-East Caribbean Dollar
    EGP-Egyptian Pound
    SVC-El Salvador Colon
    EEK-Estonian Kroon
    ETB-Ethiopian Birr
    EUR-Euro
    FKP-Falkland Islands Pound
    GMD-Gambian Dalasi
    GHC-Ghanian Cedi
    GIP-Gibraltar Pound
    XAU-Gold Ounces
    GTQ-Guatemala Quetzal
    GNF-Guinea Franc
    GYD-Guyana Dollar
    HTG-Haiti Gourde
    HNL-Honduras Lempira
    HKD-Hong Kong Dollar
    HUF-Hungarian Forint
    ISK-Iceland Krona
    INR-Indian Rupee
    IDR-Indonesian Rupiah
    IQD-Iraqi Dinar
    ILS-Israeli Shekel
    JMD-Jamaican Dollar
    JPY-Japanese Yen
    JOD-Jordanian Dinar
    KZT-Kazakhstan Tenge
    KES-Kenyan Shilling
    KRW-Korean Won
    KWD-Kuwaiti Dinar
    LAK-Lao Kip
    LVL-Latvian Lat
    LBP-Lebanese Pound
    LSL-Lesotho Loti
    LRD-Liberian Dollar
    LYD-Libyan Dinar
    LTL-Lithuanian Lita
    MOP-Macau Pataca
    MKD-Macedonian Denar
    MGF-Malagasy Franc
    MWK-Malawi Kwacha
    MYR-Malaysian Ringgit
    MVR-Maldives Rufiyaa
    MTL-Maltese Lira
    MRO-Mauritania Ougulya
    MUR-Mauritius Rupee
    MXN-Mexican Peso
    MDL-Moldovan Leu
    MNT-Mongolian Tugrik
    MAD-Moroccan Dirham
    MZM-Mozambique Metical
    MMK-Myanmar Kyat
    NAD-Namibian Dollar
    NPR-Nepalese Rupee
    ANG-Neth Antilles Guilder
    NZD-New Zealand Dollar
    NIO-Nicaragua Cordoba
    NGN-Nigerian Naira
    KPW-North Korean Won
    NOK-Norwegian Krone
    OMR-Omani Rial
    XPF-Pacific Franc
    PKR-Pakistani Rupee
    XPD-Palladium Ounces
    PAB-Panama Balboa
    PGK-Papua New Guinea Kina
    PYG-Paraguayan Guarani
    PEN-Peruvian Nuevo Sol
    PHP-Philippine Peso
    XPT-Platinum Ounces
    PLN-Polish Zloty
    QAR-Qatar Rial
    ROL-Romanian Leu
    RUB-Russian Rouble
    WST-Samoa Tala
    STD-Sao Tome Dobra
    SAR-Saudi Arabian Riyal
    SCR-Seychelles Rupee
    SLL-Sierra Leone Leone
    XAG-Silver Ounces
    SGD-Singapore Dollar
    SKK-Slovak Koruna
    SIT-Slovenian Tolar
    SBD-Solomon Islands Dollar
    SOS-Somali Shilling
    ZAR-South African Rand
    LKR-Sri Lanka Rupee
    SHP-St Helena Pound
    SDD-Sudanese Dinar
    SRG-Surinam Guilder
    SZL-Swaziland Lilageni
    SEK-Swedish Krona
    TRY-Turkey Lira
    CHF-Swiss Franc
    SYP-Syrian Pound
    TWD-Taiwan Dollar
    TZS-Tanzanian Shilling
    THB-Thai Baht
    TOP-Tonga Pa'anga
    TTD-Trinidad&amp;Tobago Dollar
    TND-Tunisian Dinar
    TRL-Turkish Lira
    USD-U.S. Dollar
    AED-UAE Dirham
    UGX-Ugandan Shilling
    UAH-Ukraine Hryvnia
    UYU-Uruguayan New Peso
    VUV-Vanuatu Vatu
    VEB-Venezuelan Bolivar
    VND-Vietnam Dong
    YER-Yemen Riyal
    YUM-Yugoslav Dinar
    ZMK-Zambian Kwacha
    ZWD-Zimbabwe Dollar
    %list%
    
    a_to.initialize(temp_list)
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Currency Conversion",<<%dlg%
    {region}
    {Region}
    ;
    {Endregion};
    {Region}
    Covert:| [.40,5From^#a_From]| To:| [.40,5to^#a_to];
    Amount:| [%z%.10Amount];
    {Endregion}; 
    {Region}
    ;
    {Endregion};
    {line=1,0};
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>;
    {endregion};
    %dlg%)
    delete x
    delete p
    f = word(from,1,"-")
    t = word(to,1,"-")
    x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")
    
    r = amount*convert_type(result,"n")
    p.from = From
    p.to = to
    p.amount = Amount
    p.result = r
    
    curr_con = p
    END FUNCTION

  2. #2
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: Currency Conversion Function

    James,

    I think I miss something.
    As I don't see any parameter I don't know how to get the wanted results.

    Ton

  3. #3
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    Ton

    You should load the function and the run it from the interactive window. The function doesn't need an argument, the drop downs will let you choose your options.

    Here is a slightly easier way to set up this function in your database.

    Attached is an export of the function from my database. Save this file on your computer. In your database, go to the control panel, code tab, right click import and select the file. Follow the import process.


    Edit: I've attached an image of what you should see when you run the function.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Currency Conversion Function

    Does it make sense to check and warn the user if the site cannot be found/internet connection not available?

    Just after the function declaration....

    Code:
    tst = http_get("http://www.webservicex.net")
    	if tst.error_code > 0 
    		ui_msg_box("Sorry","Currency conversion site not available for download.")
    		end
    	END IF

  5. #5
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    Stan

    Another sweet touch....

    You could check at the initialization and when the actual values are passed. Or add a refresh/recheck connectivity button since the internet connection may be up or down at intermittent times.

    We have a habit of construction crews cutting cables that have caused some outages lately. Probably not as bad as cutting an underwater/sea cable......
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  6. #6
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,682

    Default Re: Currency Conversion Function

    This is what the interactive window displayed:

    a=curr_con()
    ?a
    = amount = 100
    from = "TWD-Taiwan Dollar"
    result = 3.28
    to = "USD-U.S. Dollar"
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  7. #7
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    I am using this function sucessfully... thanks BIG HELP!
    BUT
    I want to always convert US to another currency and I always want just the conversion factor ie the Amount is always 1.00.
    So... i don't want the dialog boxes. I thought it would be relatively simple to modify the code so that just the factor is returned...

    Here is my latest attempt:

    'Date Created: 28-Jan-2008 04:02:17 AM
    'Last Updated: 13-Mar-2013 02:28:14 PM
    'Created By : Mr. GreenJeans
    'Updated By : David
    'a=curr_con()
    ' ?a
    ' = amount = 100
    ' from = "TWD-Taiwan Dollar"
    ' result = 3.28
    ' to = "USD-U.S. Dollar"
    'CAN'T GET THIS TO WORK!!!

    FUNCTION Curr_ConUS_Region AS a ( )

    'Create an XDialog dialog box to prompt for parameters... This script does not need the dialog... we are converting US to Current Region

    DIM SHARED From as C
    DIM SHARED to as C
    DIM SHARED Amount as N
    DIM SHARED varC_result as C

    t = lookupc("F",var->defaultregion,"currency","currencylist","Region") 'this returns "CDN-Canadian Dollar"
    f = "USD-U.S. Dollar"
    'check to see if the website is running and available...

    tst = http_get("http://www.webservicex.net")
    if tst.error_code > 0
    ui_msg_box("Sorry","Currency conversion site not available for download.")
    end
    END IF

    'x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    'result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")

    x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")

    r = amount*convert_type(result,"n")
    p.from = From
    p.to = to
    p.amount = Amount
    p.result = r

    Curr_ConUS_Region = p

    'This will return a pointer...
    'Let's populate a global Chr variable (varChar4) with the dot variable.

    Var->VarChar4 = "From " + p.from + " To " + P.To + " Amount " + p.amount + " Result: " + p.result
    Var->CurrencyCnvFactor = p.result

    END FUNCTION

    It returns 0 as the factor.

    Please help.

  8. #8
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    use

    p.result = result

    and/or

    p.result_val = val(result)


    In this example the value of amount is zero.... so r will be zero too..
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  9. #9
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    Var->VarChar4 = "From " + p.from + " To " + P.To + " Amount " + p.amount + " Result: " + p.result
    Var->CurrencyCnvFactor = p.result

    These variables are correct if I leave the dialog in.. but I want to always use USD for the t variable and a value generated by a function for the f variable.
    There must be something wrong with these lines:

    x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")

    ?maybe the 'ConversionRate?FromCurrency="+f+"&ToCurrency="+t)' syntax... it works fine when I use the dialog.

  10. #10
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    PS... you are right about the amount variable... I had placed a goto above where I initialized it to 1.00
    The function now returns the correct conversion factor... but the To / From variables are blank:
    ?curr_conUS_Region()
    = amount = 1
    from = ""
    result = 40.57
    to = ""

  11. #11
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    also replace

    f = "USD-U.S. Dollar"
    with

    f = "USD"
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  12. #12
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    oops... same problem with the From and To variables...
    VERY sorry to waste your time... but I really appreciate the help... I had been fooling with this for a long time at about 3 AM... must have been more tired than I thought!

    The following code works:

    FUNCTION Curr_ConUS_Region AS a ( )


    'Create an XDialog dialog box to prompt for parameters... This script does not need the dialog... we are converting US to Current Region

    DIM SHARED From as C
    DIM SHARED to as C
    DIM SHARED Amount as N
    DIM SHARED varC_result as C

    Amount = 1.00
    goto skip_this

    Amount = 1.00
    DELETE a_From
    DIM a_From[151] as c
    dim temp_list as c
    temp_list = <<%list%
    AFA-Afghanistan Afghani
    ALL-Albanian Lek
    DZD-Algerian Dinar
    ARS-Argentine Peso
    AWG-Aruba Florin
    AUD-Australian Dollar
    BSD-Bahamian Dollar
    BHD-Bahraini Dinar
    BDT-Bangladesh Taka
    BBD-Barbados Dollar
    BZD-Belize Dollar
    BMD-Bermuda Dollar
    BTN-Bhutan Ngultrum
    BOB-Bolivian Boliviano
    BWP-Botswana Pula
    BRL-Brazilian Real
    GBP-British Pound
    BND-Brunei Dollar
    BIF-Burundi Franc
    XOF-CFA Franc (BCEAO)
    XAF-CFA Franc (BEAC)
    KHR-Cambodia Riel
    CAD-Canadian Dollar
    CVE-Cape Verde Escudo
    KYD-Cayman Islands Dollar
    CLP-Chilean Peso
    CNY-Chinese Yuan
    COP-Colombian Peso
    KMF-Comoros Franc
    CRC-Costa Rica Colon
    HRK-Croatian Kuna
    CUP-Cuban Peso
    CYP-Cyprus Pound
    CZK-Czech Koruna
    DKK-Danish Krone
    DJF-Dijibouti Franc
    DOP-Dominican Peso
    XCD-East Caribbean Dollar
    EGP-Egyptian Pound
    SVC-El Salvador Colon
    EEK-Estonian Kroon
    ETB-Ethiopian Birr
    EUR-Euro
    FKP-Falkland Islands Pound
    GMD-Gambian Dalasi
    GHC-Ghanian Cedi
    GIP-Gibraltar Pound
    XAU-Gold Ounces
    GTQ-Guatemala Quetzal
    GNF-Guinea Franc
    GYD-Guyana Dollar
    HTG-Haiti Gourde
    HNL-Honduras Lempira
    HKD-Hong Kong Dollar
    HUF-Hungarian Forint
    ISK-Iceland Krona
    INR-Indian Rupee
    IDR-Indonesian Rupiah
    IQD-Iraqi Dinar
    ILS-Israeli Shekel
    JMD-Jamaican Dollar
    JPY-Japanese Yen
    JOD-Jordanian Dinar
    KZT-Kazakhstan Tenge
    KES-Kenyan Shilling
    KRW-Korean Won
    KWD-Kuwaiti Dinar
    LAK-Lao Kip
    LVL-Latvian Lat
    LBP-Lebanese Pound
    LSL-Lesotho Loti
    LRD-Liberian Dollar
    LYD-Libyan Dinar
    LTL-Lithuanian Lita
    MOP-Macau Pataca
    MKD-Macedonian Denar
    MGF-Malagasy Franc
    MWK-Malawi Kwacha
    MYR-Malaysian Ringgit
    MVR-Maldives Rufiyaa
    MTL-Maltese Lira
    MRO-Mauritania Ougulya
    MUR-Mauritius Rupee
    MXN-Mexican Peso
    MDL-Moldovan Leu
    MNT-Mongolian Tugrik
    MAD-Moroccan Dirham
    MZM-Mozambique Metical
    MMK-Myanmar Kyat
    NAD-Namibian Dollar
    NPR-Nepalese Rupee
    ANG-Neth Antilles Guilder
    NZD-New Zealand Dollar
    NIO-Nicaragua Cordoba
    NGN-Nigerian Naira
    KPW-North Korean Won
    NOK-Norwegian Krone
    OMR-Omani Rial
    XPF-Pacific Franc
    PKR-Pakistani Rupee
    XPD-Palladium Ounces
    PAB-Panama Balboa
    PGK-Papua New Guinea Kina
    PYG-Paraguayan Guarani
    PEN-Peruvian Nuevo Sol
    PHP-Philippine Peso
    XPT-Platinum Ounces
    PLN-Polish Zloty
    QAR-Qatar Rial
    ROL-Romanian Leu
    RUB-Russian Rouble
    WST-Samoa Tala
    STD-Sao Tome Dobra
    SAR-Saudi Arabian Riyal
    SCR-Seychelles Rupee
    SLL-Sierra Leone Leone
    XAG-Silver Ounces
    SGD-Singapore Dollar
    SKK-Slovak Koruna
    SIT-Slovenian Tolar
    SBD-Solomon Islands Dollar
    SOS-Somali Shilling
    ZAR-South African Rand
    LKR-Sri Lanka Rupee
    SHP-St Helena Pound
    SDD-Sudanese Dinar
    SRG-Surinam Guilder
    SZL-Swaziland Lilageni
    SEK-Swedish Krona
    TRY-Turkey Lira
    CHF-Swiss Franc
    SYP-Syrian Pound
    TWD-Taiwan Dollar
    TZS-Tanzanian Shilling
    THB-Thai Baht
    TOP-Tonga Pa'anga
    TTD-Trinidad&amp;Tobago Dollar
    TND-Tunisian Dinar
    TRL-Turkish Lira
    USD-U.S. Dollar
    AED-UAE Dirham
    UGX-Ugandan Shilling
    UAH-Ukraine Hryvnia
    UYU-Uruguayan New Peso
    VUV-Vanuatu Vatu
    VEB-Venezuelan Bolivar
    VND-Vietnam Dong
    YER-Yemen Riyal
    YUM-Yugoslav Dinar
    ZMK-Zambian Kwacha
    ZWD-Zimbabwe Dollar
    %list%

    a_From.initialize(temp_list)

    DELETE a_to
    DIM a_to[151] as c
    dim temp_list as c
    temp_list = <<%list%
    AFA-Afghanistan Afghani
    ALL-Albanian Lek
    DZD-Algerian Dinar
    ARS-Argentine Peso
    AWG-Aruba Florin
    AUD-Australian Dollar
    BSD-Bahamian Dollar
    BHD-Bahraini Dinar
    BDT-Bangladesh Taka
    BBD-Barbados Dollar
    BZD-Belize Dollar
    BMD-Bermuda Dollar
    BTN-Bhutan Ngultrum
    BOB-Bolivian Boliviano
    BWP-Botswana Pula
    BRL-Brazilian Real
    GBP-British Pound
    BND-Brunei Dollar
    BIF-Burundi Franc
    XOF-CFA Franc (BCEAO)
    XAF-CFA Franc (BEAC)
    KHR-Cambodia Riel
    CAD-Canadian Dollar
    CVE-Cape Verde Escudo
    KYD-Cayman Islands Dollar
    CLP-Chilean Peso
    CNY-Chinese Yuan
    COP-Colombian Peso
    KMF-Comoros Franc
    CRC-Costa Rica Colon
    HRK-Croatian Kuna
    CUP-Cuban Peso
    CYP-Cyprus Pound
    CZK-Czech Koruna
    DKK-Danish Krone
    DJF-Dijibouti Franc
    DOP-Dominican Peso
    XCD-East Caribbean Dollar
    EGP-Egyptian Pound
    SVC-El Salvador Colon
    EEK-Estonian Kroon
    ETB-Ethiopian Birr
    EUR-Euro
    FKP-Falkland Islands Pound
    GMD-Gambian Dalasi
    GHC-Ghanian Cedi
    GIP-Gibraltar Pound
    XAU-Gold Ounces
    GTQ-Guatemala Quetzal
    GNF-Guinea Franc
    GYD-Guyana Dollar
    HTG-Haiti Gourde
    HNL-Honduras Lempira
    HKD-Hong Kong Dollar
    HUF-Hungarian Forint
    ISK-Iceland Krona
    INR-Indian Rupee
    IDR-Indonesian Rupiah
    IQD-Iraqi Dinar
    ILS-Israeli Shekel
    JMD-Jamaican Dollar
    JPY-Japanese Yen
    JOD-Jordanian Dinar
    KZT-Kazakhstan Tenge
    KES-Kenyan Shilling
    KRW-Korean Won
    KWD-Kuwaiti Dinar
    LAK-Lao Kip
    LVL-Latvian Lat
    LBP-Lebanese Pound
    LSL-Lesotho Loti
    LRD-Liberian Dollar
    LYD-Libyan Dinar
    LTL-Lithuanian Lita
    MOP-Macau Pataca
    MKD-Macedonian Denar
    MGF-Malagasy Franc
    MWK-Malawi Kwacha
    MYR-Malaysian Ringgit
    MVR-Maldives Rufiyaa
    MTL-Maltese Lira
    MRO-Mauritania Ougulya
    MUR-Mauritius Rupee
    MXN-Mexican Peso
    MDL-Moldovan Leu
    MNT-Mongolian Tugrik
    MAD-Moroccan Dirham
    MZM-Mozambique Metical
    MMK-Myanmar Kyat
    NAD-Namibian Dollar
    NPR-Nepalese Rupee
    ANG-Neth Antilles Guilder
    NZD-New Zealand Dollar
    NIO-Nicaragua Cordoba
    NGN-Nigerian Naira
    KPW-North Korean Won
    NOK-Norwegian Krone
    OMR-Omani Rial
    XPF-Pacific Franc
    PKR-Pakistani Rupee
    XPD-Palladium Ounces
    PAB-Panama Balboa
    PGK-Papua New Guinea Kina
    PYG-Paraguayan Guarani
    PEN-Peruvian Nuevo Sol
    PHP-Philippine Peso
    XPT-Platinum Ounces
    PLN-Polish Zloty
    QAR-Qatar Rial
    ROL-Romanian Leu
    RUB-Russian Rouble
    WST-Samoa Tala
    STD-Sao Tome Dobra
    SAR-Saudi Arabian Riyal
    SCR-Seychelles Rupee
    SLL-Sierra Leone Leone
    XAG-Silver Ounces
    SGD-Singapore Dollar
    SKK-Slovak Koruna
    SIT-Slovenian Tolar
    SBD-Solomon Islands Dollar
    SOS-Somali Shilling
    ZAR-South African Rand
    LKR-Sri Lanka Rupee
    SHP-St Helena Pound
    SDD-Sudanese Dinar
    SRG-Surinam Guilder
    SZL-Swaziland Lilageni
    SEK-Swedish Krona
    TRY-Turkey Lira
    CHF-Swiss Franc
    SYP-Syrian Pound
    TWD-Taiwan Dollar
    TZS-Tanzanian Shilling
    THB-Thai Baht
    TOP-Tonga Pa'anga
    TTD-Trinidad&amp;Tobago Dollar
    TND-Tunisian Dinar
    TRL-Turkish Lira
    USD-U.S. Dollar
    AED-UAE Dirham
    UGX-Ugandan Shilling
    UAH-Ukraine Hryvnia
    UYU-Uruguayan New Peso
    VUV-Vanuatu Vatu
    VEB-Venezuelan Bolivar
    VND-Vietnam Dong
    YER-Yemen Riyal
    YUM-Yugoslav Dinar
    ZMK-Zambian Kwacha
    ZWD-Zimbabwe Dollar
    %list%

    a_to.initialize(temp_list)
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Currency Conversion",<<%dlg%
    {region}
    {Region}
    ;
    {Endregion};
    {Region}
    Covert:| [.40,15From^#a_From]| To:| [.40,15to^#a_to];
    Amount:| [%z%.10Amount];
    {Endregion};
    {Region}
    ;
    {Endregion};
    {line=1,0};
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>;
    {endregion};
    %dlg%)
    delete x
    delete p
    f = word(from,1,"-")
    t = word(to,1,"-")

    skip_this:

    t = lookupc("F",var->defaultregion,"currency","currencylist","Region")'+"-Canadian Dollar"
    'f = "USD-U.S. Dollar"
    't = "PHP"
    f = "USD"

    From = "USD-US Dollars"
    To = t

    'check to see if the website is running and available...

    tst = http_get("http://www.webservicex.net")
    if tst.error_code > 0
    ui_msg_box("Sorry","Currency conversion site not available for download.")
    end
    END IF

    'x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    'result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")

    x = http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency="+f+"&ToCurrency="+t)
    result = extract_string(x.body,"<double xmlns=\"http://www.webserviceX.NET/\">","</double>")

    r = amount*convert_type(result,"n")
    p.from = From
    p.to = to
    p.amount = Amount
    p.result = r
    'p.result_val = val(result)

    Curr_ConUS_Region = p

    'This will return a pointer...
    'Let's populate a global Chr variable (varChar4) with the dot variable.

    Var->VarChar4 = "From " + p.from + " To " + P.To + " Amount " + p.amount + " Result: " + p.result
    Var->CurrencyCnvFactor = p.result

    END FUNCTION

  13. #13
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    The code was working until a couple of days ago... I didn't change anything BUT
    when I enter the following, there is obviously something wrong.

    x=http_get("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=CAD&ToCurrency=USD")
    ?x
    = body = System.IO.IOException: There is not enough space on the disk.

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
    at System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer)
    at System.IO.FileStream.Dispose(Boolean disposing)
    at System.IO.Stream.Close()
    at System.IO.StreamWriter.Dispose(Boolean disposing)
    at System.IO.TextWriter.Dispose()
    at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
    at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
    at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
    at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
    at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
    at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
    at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
    at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
    at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
    at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
    at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
    at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
    at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

    error_code = 0
    error_text = ""
    headers = HTTP/1.1 500 Internal Server Error
    Cache-Control: private
    Content-Length: 2088
    Content-Type: text/plain; charset=utf-8
    Server: Microsoft-IIS/7.0
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Tue, 02 Apr 2013 14:51:39 GMT
    Connection: close
    +parsed_headers.

    What has happened??

  14. #14
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    Is this the error?

    = body = System.IO.IOException: There is not enough space on the disk.

    Did your server drive fill up?
    Although I get the same message on a5v 10.5
    Looks like something changed/broke (disk filled up...) on the www.webservicex.net site...
    Last edited by Al Buchholz; 04-02-2013 at 01:03 PM.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  15. #15
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    I am pretty sure that the problem is with the website... That is where the "There is not enough room..." message is coming from.
    It looks like the website has been changed... maybe it's broken & it will work after they fix it... or... they may have changed it forever.
    Hope not!

  16. #16
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    Quote Originally Posted by David Boomer View Post
    I am pretty sure that the problem is with the website... That is where the "There is not enough room..." message is coming from.
    It looks like the website has been changed... maybe it's broken & it will work after they fix it... or... they may have changed it forever.
    Hope not!
    I agree that it's the website. I tested with a browser and got the same results.

    Maybe they are a day late for April 1.....
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  17. #17
    Member
    Real Name
    David Boomer
    Join Date
    Apr 2000
    Location
    Brampton Ontario, Canada
    Posts
    662

    Default Re: Currency Conversion Function

    Thanks Al...
    The lesson here is... don't include important functionality in your app that depends on someone else's website!

  18. #18
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default Re: Currency Conversion Function

    Quote Originally Posted by David Boomer View Post
    Thanks Al...
    The lesson here is... don't include important functionality in your app that depends on someone else's website!
    And have a lot of error checking routines and alternate options for functionality...
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

Similar Threads

  1. Currency Fields?
    By Ralf in forum Alpha Five Version 8
    Replies: 7
    Last Post: 06-29-2007, 04:19 PM
  2. New string to date conversion function
    By Tom Cone Jr in forum Archived Wishlist
    Replies: 14
    Last Post: 11-04-2005, 04:21 PM
  3. Currency formats
    By Doug Hawkins in forum Alpha Five Version 5
    Replies: 10
    Last Post: 12-12-2002, 03:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •