ExamplesThe following code samples show how different types of applications can use the services provided by Currency Server. Simple Conversions (VBScript)In this VBScript example the ConvertToNum and ConvertToStr methods of the Server object are used to perform simple currency conversions. The Currencies 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 currencies USD and JPY, 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++)This 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. Includes an option to connect via DCOM. 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 shows a simple ASP page using Currency Server to provide exchange rate information and currency conversion functionality. Download and Upload (VBasic)This piece of Visual Basic code (source and object code are included) can be launched as a "Custom Action after Update" (Clients tab of Currency Server Manager) or from a command line, or from the Windows Task Scheduler. It fetches the rates from Currency Server, and uses the Windows Web Publishing APIs to upload a file in SERIFF (INI), CSV or XML format to the URL or local file specified in the command line. A script like this could for example be used to post daily exchange rates for Euro Calculator clients. The supported output formats are INI, CSV and XML. With small changes, an HTML table could be generated instead. This script requires the Web Publishing Wizard software and the Visual Basic run-time DLL MSVBVM60.DLL or higher. The recommended installation folder is the "Actions" subdirectory of the Currency Server installation directory. To run curncupl.exe use the following format: currencyuploader.exe Destination [/u:UserName] [/p:Password] [/t:FileType] [/b:BaseCurrency] [/n:CurrencyNames] [/g:Language] [/i:TitleStyle] [/d:DateOnly] [/l:LogPath]
The defaults for the options are: /t:INI /b:EUR /n:1 /g:EN /i:1 /d:0
Sample Conversion Filter (VBScript)This sample code shows how to write a data conversion filter, which can then be accessed from the FX Servers tab of Currency Server Manager (Add/Edit Server 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. |