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

Feedback Form (ExpandCollapse)

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.