Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Currency Conversion Function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    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
    Most things are simple but unfortunately only after the first time

    Comment


      #3
      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.
      "Make it as simple as possible, but not simpler."
      Albert Einstein

      http://www.iadn.com/images/media/iadn_member.png

      Comment


        #4
        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
        There can be only one.

        Comment


          #5
          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.
          "Make it as simple as possible, but not simpler."
          Albert Einstein

          http://www.iadn.com/images/media/iadn_member.png

          Comment


            #6
            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

            Comment


              #7
              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.

              Comment


                #8
                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.
                "Make it as simple as possible, but not simpler."
                Albert Einstein

                http://www.iadn.com/images/media/iadn_member.png

                Comment


                  #9
                  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.

                  Comment


                    #10
                    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 = ""

                    Comment


                      #11
                      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.
                      "Make it as simple as possible, but not simpler."
                      Albert Einstein

                      http://www.iadn.com/images/media/iadn_member.png

                      Comment


                        #12
                        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

                        Comment


                          #13
                          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??

                          Comment


                            #14
                            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, 12: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.
                            "Make it as simple as possible, but not simpler."
                            Albert Einstein

                            http://www.iadn.com/images/media/iadn_member.png

                            Comment


                              #15
                              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!

                              Comment

                              Working...
                              X