Unformatted text preview:

WMLScript INTRODUCTION What is WMLScript WMLScript is a client side scripting language based on ECMAScript which is based on Netscape s JavaScript language whose purpose is to provide client side procedural logic It provides general scripting capabilities to the Wireless Application Protocol WAP architecture Specifically WMLScript complements the Wireless Markup Language WML While WML focuses on content it is a declarative document markup language designed to convey the essence of a user interface WMLScript is imperative language which focuses on procedure and logic WMLScript belongs to the application layer of the WAP archicture and makes use of services and facilities of the lower layers It causes WML documents to interact with the users WMLScript is to WML is like JavaScript is to HTML WMLScript is the JavaScript of the wireless world WMLScript has a weak type definition which means that variable types are not defined during declaration the data types are determined during execution While the WMLScript code is maintained on the servers the script execution takes place on the local device What is WMLScript used for WML which is based on Extensible Markup Language XML specifies application content for narrowband devices like cell phones WML allows simple formatting to make the user interface more readable but its content is static with the following limitations 1 checking the validity of user input 2 Access to facilities of the device For example on a phone allow the programmer to make phone calls send messages etc 3 Generating messages and dialogs locally thereby reducing the need for expensive round trips to show alerts error messages confirmations etc 4 Allowing extensions to the device software and configuration of the device after it has been deployed WMLScript is designed to overcome these limitations and to provide programmable functionality that can be used over narrowband communication links in clients with limited capabilities WmlScript is a function oriented scripting language which enhances WML applications WMLScript focuses on procedure and logic It adds dynamic code to static WML data For example when validating form field entries providing rapid responses and calculations for expanding the normal functions to mobile phones sending messages and dialogs and even for creating games Many of the services that can be used with thin mobile clients can be implemented with WML Scripting enhances the standard browsing and presentation facilities of WML with behavioral capabilities They can be used to support more advanced User Interface UI functions add intelligence to the client provide access to the device and its peripheral functionality and reduce the amount of bandwidth needed to send data between the server and the client WMLScript Vs JavaScript WMLScript is simple scripting language similar to JavaScript but there are quite a lot of differences between the two While HTML documents normally contain embedded JavaScript code WML only contains references to the URL addresses of a WMLScript function Unlike HTML in which the JavaScript code is compiled along with HTML WMLScript has to be compiled into binary code before being executed on a WAP device Therefore a WMLScript Virtual Machine has to be included in the browser that executes the script To speed up data transfer WMLScript libraries are pre compiled and loaded to the user agent s memory providing quick access to the WMLScript script JavaScript does not support call by address whereas it is supported in WMLScript That is an argument can be set inside a function and communicated back to the caller JavaScript on the other hand supports call by value that is functions can read parameter values from their caller but cannot change these values in the caller s scope How to call a WMLScript function WMLScript code is written in normal text files with the extension wmls for example script1 wmls These text files are placed on the same server as normal WML documents however it is also possible to call WMLScript functions on other servers from within WML documents or from WMLScript code A text file is called a compilation unit and it may contain one or several functions A compilation unit can be placed in the same directory as WML documents or in a separate subdirectory Functions that have similar properties should be placed in the same compilation unit When a WML document contains a reference to a WMLScript function the call will be routed from the browser through the gateway to the server The server will then send the necessary WMLScript compilation which is converted into binary format in the gateway The reason for this is that binary file is smaller and therefore easier to transmit over a wireless network The binary file is sent from the gateway to the WAP browser The WAP browser has an interpreter that is able to execute WMLScript programs in their binary format WMLScripts are not embedded in WML pages The WML pages only contain references to script URL s In the example below a card is created where you enter a URL select the go label and then go off to the specified URL xml version 1 0 DOCTYPE wml PUBLIC WAPFORUM DTD WML 1 1 EN http www wapforum org DTD wml 1 1 xml wml card id no1 title Go to URL do type options label Go go href check wmls go url my url do p Enter a URL input type text name my url p card wml The red line above contains a reference to a WMLScript The script is in a file called check wmls and the name of the function is go url The go url function sends you to the URL you entered The function also checks if you omitted the http part in the URL The same reference system is used for calling WMLScript functions as in HTML and WWW which means that resources are referred to with their relative or absolute addresses The call should always include the name of the target WMLScript function and its list of parameters The call may be absolute or relative The WMLScript function may call functions within the same compilation unit or functions in other compilation units or libraries Here is the WML page called check wmls Extern function go url the url if String find the url http 0 the url http the url WMLBrowser go the url If the WMLScript function is defined with the word extern it can be called from any other compilation unit unless it is protected by access control programs The extern keyword is used to allow other functions access to this function or WML events outside the wmls file WMLScript Bytecode Interpreter


View Full Document

WVU CS 486 - WMLScript

Course: Cs 486-
Pages: 12
Loading Unlocking...
Login

Join to view WMLScript and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view WMLScript and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?