WMLScript Tutorial
WMLScript (Wireless Markup Language Script) is the partner of WML. It is a client-side scripting language that is very similar to JavaScript. Our WMLScript tutorial begins with an overview of WMLScript and its language rules. Then we will look at functions and variables. You can learn how to define functions, how to declare variables, etc. Operators, conditional and looping statements will be covered afterwards. The WMLScript standard library contains a lot of useful functions. We will go through some of the commonly used ones. At the end of the WMLScript tutorial, we will demonstrate how to write scripts to validate forms and submit data to the WAP server.
Plenty of code examples are given in the WMLScript tutorial to help you understand the concepts and techniques.
Table of Contents
1.2. WMLScript MIME Type and File Extension
2. Hello World WMLScript Example
4.1. Semicolons at the End of WMLScript Statements
4.3. Case Sensitivity in WMLScript
4.5. String Literals in WMLScript
5. Defining WMLScript Functions
5.2. WMLScript Function Naming Conventions
5.3. WMLScript Function Arguments
6. Calling WMLScript Functions
6.1. Calling a Function Located in the Same WMLScript File
6.2. Calling a Function Located in a Different WMLScript File
6.3. Calling a Function from a WML Card
6.3.1. Passing Arguments to Functions
7.1. Declaring WMLScript Variables Using the var Keyword
7.2. WMLScript Variable Naming Conventions
7.3. Scope and Lifetime of WMLScript Variables
9. WMLScript Variables Vs WML Variables
9.1. Using WMLScript to Set the Value of a WML Variable
9.2. Using WMLScript to Obtain the Value of a WML Variable
10. Passing Arguments to Functions By Value and By Reference
11.1. WMLScript Arithmetic Operators - Performing Math Operations
11.1.1. Basic Math Operations - Addition, Subtraction, Multiplication, Division, Finding Remainders
11.1.2. Pre/Post Increment and Decrement
11.1.3. Bitwise Operations - Dealing with Binary Representations of Numbers
11.2. WMLScript Assignment Operators - Assigning Values to Variables
11.3. WMLScript Logical Operators - Performing Boolean Operations
11.4. WMLScript Comparison Operators - Checking Two Values against a Certain Condition
11.6. WMLScript String Operators - Concatenating Strings
11.7. WMLScript typeof Operator - Finding Data Types of Variables
11.8. WMLScript isvalid Operator - Finding if a Variable is of the Invalid Data Type
12. WMLScript Conditional Statements
13. WMLScript Looping Statements
13.3. break Statement: Quitting a Loop
13.4. continue Statement: Quitting Current Iteration of a Loop
14. WMLScript Standard Libraries Overview
14.1. How to Call a Function in the WMLScript Standard Libraries
15. WMLScript WMLBrowser Standard Library
15.1. Going Forwards / Backwards to WML Cards: go() and prev() Functions
15.2. Clearing Variables and URL History: newContext() Function
15.3. Getting the Current WML Card's URL: getCurrentCard() Function
15.4. Getting and Setting WML Variable Values: getVar() and setVar() Functions
15.5. Refreshing the Current Card on the WML Browser: refresh() Function
16. WMLScript Dialogs Standard Library
16.1. Displaying Messages on the Screen of Wireless Devices: alert() Function
16.2. Displaying Confirmation Messages on the Screen of Wireless Devices: confirm() Function
16.3. Displaying Input Fields and Getting Data from Users: prompt() Function
17. WMLScript String Standard Library
17.1. Getting the Character at a Certain Index in a String: charAt() Function
17.2. Getting the Number of Characters in a String: length() Function
17.3. Removing All Leading and Trailing Whitespaces of a String: trim() Function
17.4. Finding if a Certain Substring Exists in a String: find() function
17.5. Replacing a Substring with Another Substring: replace() Function
17.6. Manipulating Elements in Strings
17.6.1. Getting the Number of Elements in a String: elements() Function
17.6.2. Getting the Element at a Certain Index in a String: elementAt() Function
17.6.3. Inserting an Element at a Certain Position in a String: insertAt() Function
17.6.4. Removing the Element at a Certain Index in a String: removeAt() Function
17.6.5. Replacing an Element at a Certain Index with Another Element: replaceAt() Function
17.7.2. Assigning Elements to an Array
17.7.3. Getting Elements of an Array
17.7.4. Changing the Value of an Array Element
18. WMLScript Float Standard Library
18.1. Rounding a Numeric Value: round() Function
18.2. Truncating the Fractional Part of a Numeric Value: int() Function
18.3. Raising a Numeric Value to the Power of Another Numeric Value: pow() Function
18.4. Calculating the Square Root of a Numeric Value: sqrt() Function
18.5. Calculating the Ceiling of a Numeric Value: ceil() Function
18.6. Calculating the Floor of a Numeric Value: floor() Function
19. WMLScript Lang Standard Library
19.1. Generating Random Numbers: seed() and random() Functions
19.4. Calculating the Absolute Value of a Numeric Value: abs() Function
19.5. Checking Whether the Conversion of a String into an Integer is Possible: isInt() Function
19.6. Converting a String to an Integer: parseInt() Function
19.8. Converting a String to a Floating-point Number: parseFloat() Function
20. WMLScript URL Standard Library
20.1. Getting the Current WMLScript Document's URL: getBase() Function
20.3. Extracting the Query String of an URL: getQuery() Function
20.4. Extracting Query Parameters of an URL
21. WMLScript Example: Validating Form Data
21.1. Retrieving Form Data and Removing Leading and Trailing Whitespaces
21.2. Checking Whether All Required Fields Has been Filled
21.3. Checking the Length of Password
21.4. Validating Email Address