O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required