14. WMLScript Standard Libraries Overview
There are six standard libraries totally. Here is an overview of them:
The WMLBrowser library provides a group of functions to control the WML browser or to get information from it.
The Dialogs library contains functions for displaying alert messages, confirmation messages and input boxes to users.
The String library provides a number of functions that help us manipulate strings.
The Float library contains functions that help us perform floating-point arithmetic operations.
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.
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.
14.1. 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:
The following WMLScript example demonstrates how to call the sqrt() function of the Float standard library to calculate the square root of a 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.
|Previous Page||Page 30 of 71||Next Page|
- 1. WMLScript Introduction
- 2. Hello World WMLScript Example
- 3. Compiling WMLScript Code
- 4. WMLScript Language Rules
- 5. Defining WMLScript Functions
- 6. Calling WMLScript Functions
- 7. WMLScript Variables
- 8. WMLScript Data Types
- 9. WMLScript Variables Vs WML Variables
- 10. Passing Arguments to Functions By Value and By Reference
- 11. WMLScript Operators
- 12. WMLScript Conditional Statements
- 13. WMLScript Looping Statements
- 14. WMLScript Standard Libraries Overview
- 15. WMLScript WMLBrowser Standard Library
- 16. WMLScript Dialogs Standard Library
- 17. WMLScript String Standard Library
- 18. WMLScript Float Standard Library
- 19. WMLScript Lang Standard Library
- 20. WMLScript URL Standard Library
- 21. WMLScript Example: Validating Form Data