Chapter 12. WMLScript Statements

This chapter covers WMLScript statements, which provide such useful control structures as loops and conditions, as well as simpler features such as the ability to return a value from a function.

Almost all of these features are similar to those found in languages such as C and Java, except that WMLScript doesn’t provide quite the same rich selection. For example, there is no switch statement, and none of the extra statements found in Java are present in WMLScript.

This shouldn’t be a problem, however. WMLScript was designed only for simple operations, such as checking that input is valid before sending it to the server. For anything complicated enough to need many more features, you’ll probably be doing the real work on the server anyway.

Expressions as Statements

Any WMLScript expression can be turned into a statement by simply following it with a semicolon. This means that the expression is evaluated, but its result is thrown away. Any side effects of the expression still occur, however. The most common types of expressions to use as statements are the various assignments. (These are used far more often as statements than as expressions.)

For example:

a = b;
foo ( );
x++;
total += value;

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.