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:


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


A button for going back to the top of this page