Cloanto    Home      Products & Services      Purchase      Support      Search: Go
Currency System :: Currency Server :: Code Samples
System Overview
Currency Server
:: Overview
:: Features
:: Screenshots
:: Options
:: FX Feeds
:: World Monitor
:: Code Samples
:: Requirements
:: Download
:: Evaluation
:: Upgrades
Managed Services
Web Tools
Calculators
Purchase
Support

Examples

The following code samples show how different types of applications can use the services provided by Currency Server. You may also want to check out the Code Examples section, under Getting Started, in the Currency Server documentation. The documentation also covers the various programming interfaces.

Simple Conversions (VBScript)

In the following VBScript example the Convert method of the Server object is used to perform simple currency conversions, both with numerical and with formatted string results. The ActiveCurrencies collection is then used to build a list of the available currencies and show their exchange rates with respect to other currencies. The first two steps of this example make a hard-coded reference to the USD and JPY currencies, and will fail if the currencies are not defined in Currency Server. The second two steps automatically get a list of all available currencies.

Simple Conversions (C++)

The following is a C++ version of the previous example. It is designed to use the native COM support of Microsoft Visual C++ version 5.0 or higher. It includes an option to connect via DCOM.

Simple Conversions (C#)

The following is a C# version of the previous examples, packaged as a Visual Studio 2008 solution. To create the project in Visual Studio right-click the References folder in Solution Explorer, then select Add Web Reference. If Add Web Reference is not available, select Add Service Reference, then in the Add Service Reference dialog select Advanced, and in the Service Reference Settings dialog select Add Web Reference. In the Add Web Reference dialog enter the web service URL (e.g. http://localhost/CurrencyServer/CurrencyServer5.asmx) and select Go. Specify a name for the web reference (e.g. CurrencyServerService) and select Add Reference.

Adding a Conditional Commission (VBScript)

This example shows how to add a currency exchange commission (e.g. as applied by banks or credit card companies) to conversions. Unlike other services which are sometimes offered online, this procedure recognizes conversions between currencies which have joined the European Economic and Monetary Union (EMU), and does not apply any commission when both currencies belong to the EMU, as these units are both sub-units of the same currency (the euro), and both banks and credit card companies usually apply the official conversion rates. (Constant service fees are not considered by this procedure.)

Active Server Pages (ASP)

This example features a simple ASP page using Currency Server to provide exchange rate information and currency conversion functionality.

Widget Skeleton (JavaScript)

This example features a simple HTML page (as shown here) illustrating the Currency System Script Library used to obtain convert-as-you-type functionality. In addition to writing numerical amounts, currency codes can be typed in the text (before or after the number) to change the From and To currencies without using the mouse.

Sample Conversion Filter (VBScript)

This sample code shows how to write a data conversion filter, which can then be accessed from the FX Feeds tab of Currency Server Manager (Add/Edit FX Feed dialog).

To install the filter copy the contents of the archive to the "Filters" subdirectory of the Currency Server installation directory.

The "input.txt" file represents a sample set of data in the format which the filter was designed to process. Make sure that the Address field points to this file, which can be stored locally or on the internet.

The "output.ini" file is included in the archive for demonstration purposes only, and shows a sample output file of the filter. The actual data output by the filter is normally written to a temporary location and then deleted by Currency Server.

For debugging purposes, when writing a new filter you may want to enable full Input and Output logging in the Notifications tab of Currency Server Manager.

© 1998-2024 Currency System, Inc. All rights reserved.      Legal      Privacy