Welcome to Developer's Home Sunday, April 20, 2014
Home - DevelopersHome.com

WMLScript Standard Libraries Overview


Preferences - Do not show ads

WMLScript is based on ECMAScript, which is the standardized version of JavaScript. However, some functionality of ECMAScript has been taken away in order to increase the efficiency of WMLScript. To keep WMLScript sufficiently powerful, a number of standard libraries are added to it. Functions in the WMLScript standard libraries can perform tasks that cannot be easily implemented or are impossible to be implemented by writing your own WMLScript code.

There are six standard libraries totally. Here is an overview of them:


1. WMLBrowser library
The WMLBrowser library provides a group of functions to control the WML browser or to get information from it.


2. Dialogs library
The Dialogs library contains functions for displaying alert messages, confirmation messages and input boxes to users.


3. String library
The String library provides a number of functions that help us manipulate strings.


4. Float library
The Float library contains functions that help us perform floating-point arithmetic operations.


5. Lang library
The Lang library provides functions related to the WMLScript language core. It contains functions for generating random numbers, performing some arithmetic operations and dealing with data type conversion.


6. URL library
The URL library contains functions that help us manipulate URLs.


The WMLScript standard libraries are included in the WAP specification. Hence, mobile devices that support WMLScript should also support the WMLScript standard libraries. Note that the Float library is only available on mobile devices that can perform floating-point calculations.

WMLScript programmers should get familiar with the standard libraries. With such knowledge, you can know whether a particular task can be done by using the functions in the standard libraries. If the standard libraries do not have the function you need, that means you have to implement the function yourself or the task cannot be done with the WMLScript language.


How to Call a Function in the WMLScript Standard Libraries

Calling a function in the WMLScript standard libraries is simple. It is the same as calling your own function, except that you have to add the library name and a dot character before the function name. This is the syntax:


library_name.function_name(parameter1, parameter2...);


The following WMLScript example demonstrates how to call the sqrt() function of the Float standard library to calculate the square root of a number:


function findSquareRoot(number)
{
  return Float.sqrt(number);
}


In the following sections, we will introduce to you each of the standard libraries and provide an in depth coverage of the commonly used functions.


Page 30 of 71 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top
Custom Search

Feedback Form (Expand)

What do you think about this web page?






WMLScript Tutorial Table of Contents WMLScript Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page