Chapter 2. WML Variables and Contexts
A significant difference between WML and HTML is that WML supports variables. WML variables contain strings, and these strings can be inserted into the body text of the WML document or into the values of certain attributes. The values of variables can be changed under the control of the WML itself and also from within WMLScript functions (more on these later).
The names of WML variables can consist of any combination of letters, digits, and underscores, except that the first character must not be a digit. Like most things in WML, variable names are case-sensitive. The following are all examples of legal variable names:
a foo __name_with_underscores__ _ ThisVariableNameIsImpracticalBecauseItIsTooLong xy17
The following are examples of invalid variable names:
17xy (starts with a digit) name with spaces (space is not a letter, digit, or underscore)
Although WML doesn’t impose a limit on the length of variable names, remember that the full name needs to be transmitted over a low-bandwidth link and then stored in the (possibly limited) memory on the device running the browser. As a result, it’s a good idea to keep your variable names short.
Variable Substitution
Variables can be inserted (or substituted ) into the body text or an attribute value in one of three ways:
$name $(name) $(name:conversion)
If the first form is used, the variable name must be followed by some character that’s illegal in variable names (any character other than a letter, digit, or ...
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.