11.4. WMLScript Comparison Operators - Checking Two Values against a Certain Condition
A comparison operator takes two operands, checks their values against a certain condition and returns true or false depending on whether the condition is satisfied. Six comparison operators are available in WMLScript:
==
Checks whether two values are equal.!=
Checks whether two values are not equal.<
Checks whether a value is less than another value.<=
Checks whether a value is less than or equal to another value.>
Checks whether a value is greater than another value.>=
Checks whether a value is greater than or equal to another value.
The following WMLScript examples demonstrate how to use the comparison operators:
The == Operator:
x
= (99==99);
y = ("WMLScript Tutorial"=="WMLScript
Tutorial");
z = ("wmlscript tutorial"=="WMLScript
Tutorial");
After executing the script, x and y contain the true value and z contains the false value since string comparisons are case-sensitive in WMLScript.
The != Operator:
x
= (99!=100);
y = (99!=99);
After executing the script, x and y contain the true and false value respectively.
The < and <= Operators:
x
= (90<99);
y = (90<=99);
After executing the script, both x and y contain the true value.
x
= (100<99);
y = (100<=99);
After executing the script, both x and y contain the false value.
x
= (99<99);
y = (99<=99);
After executing the script, x has the value false while y has the value true.
The > and >= Operators:
x
= (90>99);
y = (90>=99);
After executing the above script, both x and y have the false value.
x
= (100>99);
y = (100>=99);
After executing the above script, both x and y have the true value.
x
= (99>99);
y = (99>=99);
After executing the above script, x contains the value false while y contains the value true.
Previous Page | Page 21 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