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


Feedback Form (ExpandCollapse)

What do you think about this web page?






(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.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page