|
Writing A Multi-Currency Converter Using WMLScript
by Wei Meng LEE
|
Introduction
In the past few months, we have seen a lot of articles describing how WMLScript can be used to perform client-side validation
and complement WML applications that runs on a WAP device. One particular application that is very popular is a currency converter.
However, the conventional currency converter usually hardcodes the exchange rate in the WMLScript program. Once the WMLScript is downloaded
onto the device, it is cached and any changes to the currency conversion rate would not be reflected in the application.
In this article, I will illustrate how you can use ASP to create a truly "dynamic" WMLScript program using the currency converter
application as a case study. Our currency converter is able to reflect the daily changes in the exchange rates.
The Application
The currency converter application is typically used to illustrate the use of WMLScript. For this article, I will use the UP.Simulator
provided by Phone.com. The following figures illustrate our application:
The user simply chooses the currency to convert from, punch in the amount to be converted and selects the target currency and the
converted currency would then be displayed.
The Database
Our application makes use of a database containing a single table named Conversion.
This table simply contains the exchange rate of currencies. The exchange rate is tagged to a fixed currency, the Singapore dollar (SIN),
in this case. For example:
1 USD (US Dollar)= 1.73 SIN (Singapore Dollar)
1 RM (Malaysian Ringgit)= 0.48 SIN
Converting from one currency to another is a two-step process. For example, to convert 15 USD to RM, first convert the USD to SIN:
15 * 1.73 = 25.95 SIN
Then convert the SIN to RM:
25.95 / 0.48 = 54.0625 RM
The Conversion table contains two fields: Currency and SinEquiv. The Currency field contains the currency name while
the SinEquiv field contains the equivalent amount of the currency in Singapore dollar.
Next: The WML Deck
|