WMLScript

WMLScript

DOI: 10.4018/978-1-59140-769-0.ch008
OnDemand:
(Individual Chapters)
Available
$37.50
No Current Special Offers
TOTAL SAVINGS: $37.50

Abstract

WML is a markup language used for text formatting and displaying (Open Mobile Alliance, 2001). However, the functions of a markup language are limited if there is no support from other programming languages. Two kinds of programming languages can help to extend the functions of WML: 1. server-side scripts such as CGI Perl running on servers, and 2. client-side scripts such as WMLScript running on handheld devices. This chapter focuses on WMLScript, building on the descriptions of WML and CGI provided in the previous two chapters. WMLScript (Open Mobile Alliance, 2000a) is a light JavaScript language (Netscape Communications Corporation, n. d.) that must be compiled into byte code on a server before it can run on a handheld device. It is based on ECMAScript but has been modified to better support low bandwidth communication and thin clients. WMLScript can be used in conjunction with WML to provide intelligent content to clients, but can also be used as a stand alone tool.
Chapter Preview
Top

Introduction

WML is a markup language used for text formatting and displaying (Open Mobile Alliance, 2001). However, the functions of a markup language are limited if there is no support from other programming languages. Two kinds of programming languages can help to extend the functions of WML:

  • 1.

    server-side scripts such as CGI Perl running on servers, and

  • 2.

    client-side scripts such as WMLScript running on handheld devices.

This chapter focuses on WMLScript, building on the descriptions of WML and CGI provided in the previous two chapters. WMLScript (Open Mobile Alliance, 2000a) is a light JavaScript language (Netscape Communications Corporation, n. d.) that must be compiled into byte code on a server before it can run on a handheld device. It is based on ECMAScript but has been modified to better support low bandwidth communication and thin clients. WMLScript can be used in conjunction with WML to provide intelligent content to clients, but can also be used as a stand alone tool.

Top

Wmlscript Activation

Unlike JavaScripts, which are embedded in HTML pages, WMLScripts are not embedded in WML pages. To activate a WMLScript from a WML page, the page contains references to the URL of the WMLScript. Figure 1 shows how to call a WMLScript from a WML page. The example shown is a single-item selection for displaying the selected sports page. Assume the WML script in Figure 1 is located at http://people.cs.und.edu/~userid/handheld/wmls/Functions.wmls. The activation uses the href attribute of the go element to find the destination WMLScript and sends an argument $(item) storing the item selected.

Figure 1.

The WML script Activate.wml showing how to activate a WMLScript

978-1-59140-769-0.ch008.f01
Figure 2.

The function goto activated by the WML page in Figure 1

978-1-59140-769-0.ch008.f02

The WMLScript function goto in Figure 2 is in a file called Functions.wmls and the function uses the extern keyword. When using this keyword, the function can be called by other functions or WML events outside the .wmls file. To keep a function private, the extern keyword must be dropped. The optional extern keyword can be used to specify a function to be externally accessible. Such functions can be called from outside the compilation unit in which they are defined. There must be at least one externally accessible function in a compilation unit. This function checks whether the item, for example NBA or NFL, is selected. If it is, the corresponding homepage is displayed; if not, the message “Not found” is shown. It uses three features of WMLScript, which will be explained in more detail later:

  • 1.

    If statement,

  • 2.

    The go function of the WMLBrowser library, which goes to a new card, specified by the new URL, and returns an empty string, and

  • 3.

    The alert function of the Dialog library, which displays a message, waits for a confirmation, and then returns an empty string.

Complete Chapter List

Search this Book:
Reset