You’ve now seen nearly all the elements that make up WMLScript, but one thing that hasn’t yet been properly covered is how you wrap these bits up into functions that can be called from WML.
That process is covered in this chapter, together with how you can put commonly used WMLScript functions into a single library and call these from different places.
Functions are declared after any pragmas (more on pragmas in Chapter 14). A function declaration looks like either:
If the function is declared
, it’s available to be called
from WML or from other WMLScript functions not declared in the same
file. If it’s declared without the
keyword, it can be called only by other WMLScript code in the same
The function name follows the same rules as WMLScript variable names: anything that is a legal variable name is a valid function name. In addition, you can use the same name for a variable and a function, since WMLScript keeps separate namespaces for each.
The function body is simply a list of WMLScript statements.
is a list of the names of each of the parameters to the function. These names follow the same rules as variable names. This is not surprising, since in the function body ...