Introducing WML and WMLScript: Operating the Nokia WAP Toolkit | WebReference

Introducing WML and WMLScript: Operating the Nokia WAP Toolkit

Introducing WML and WMLScript

Operating the Nokia WAP Toolkit

The Nokia WAP Toolkit comes with a few example programs in the Samples directory, under the installation directory. Copy them to your working directory so you can modify them without risking the integrity of the original files. We'll focus in this column on two examples provided by Nokia that include WMLScript code: mortgage, and currency. Let's look first on the currency application and follow its operation, step by step. It provides the user agent with an intuitive, simple-to-use program that convert a given sum from one currency to another. Open the file currency.wml. Your Nokia WAP Toolkit should look like the image shown on the previous page.

The first thing you need to do is to send the application to the user agent (Nokia 6150). WML is a compiled language and so is WMLScript. To compile the WML code, click on the Compile button on the bottom left corner. If you'll look in your working directory, you will see a new file, currency.wmlc (a compiled wml). You should also open the file currency.wmls and compile it, generating the file currency.wmlsc. Return to the main application currency.wml and press the Show button on the bottom left corner. Your Nokia 6150's display should post the currency application's user interface, as shown here:

A few words about the Nokia 6150 is in order. All its buttons are operational including the on/off button. You enter alphanumeric characters via its regular keys. The most important key is the up/down key just underneath the display, in the center of the device. On the up/down key's two sides are two "soft keys". They are called "soft" because their function is software-programmable and shown by the display on its bottom left and right corners. The image above shows that the left soft key has the Options functionality. You'll see below other functions that these soft keys can be assigned.

The Nokia 6150 shows now the currency conversion parameters. Navigate between them using the up/down key. Currently, it reads:

Amount [] from [US DOLLARS] to [Finnish Markka] =

Let's convert 100 French Francs to US Dollars. Navigate to the Amount field with the up/down key. Press the left soft key, labeled Options. You get a new screen, consisting of a menu and two soft keys (Select and Back). The menu includes two entries, Edit Amount and Calculate:

Click on the Select soft key. An entry field will show up. Enter 100.00:

Notice that the name of the entry field, Amount:, is taken from the source code. The 123 icon on the top left corner reminds you that this is a numeric field only. Click the OK soft button. You'll get the following display:

Press the arrow down key to navigate to the next field, the From field:

Click the Options soft key. If you scroll the options with the up and down arrow keys, you will see three options to choose from: Edit From, Calculate, and Help:

Stay on the Edit From option and press the Select soft key. You get the options for the From field. Navigate up and down until you find French Franc:

Press the Select soft key. Notice how the circle to left of your selection gets an inner circle:

Approve your selection by clicking on the OK soft key. Let's navigate now to the To: field. Use the up and down arrow keys to reach the next entry field:

Repeat the sequence above for this field. Change the target currency to US Dollar:

Finally, click the Options soft key and get again the Browser Options:

Navigate to the Calculate option and click the Select soft key. The display will return automatically to a screen labeled "Currency". Navigate to the bottom of the screen and see the result of the computation:

Next: How to program in WML - Part I

Produced by Yehuda Shiran and Tomer Shiran

Created: May 8, 2000
Revised: May 8, 2000