The related WMLScript statements can be executed together as the unit known as the
function. A function declaration in WML has the following syntax:
A D V E R T I S E M E N T
extern function identifier(FormatParameterList)
Block ;
The keyword extern is optional and it is used to specify the function which can be called
from outside a current compilation unit in which that function is been defined. A sample
function declaration of WMLScript looks this:
function RunTime(distance, speed)
{
var time = distance / speed;
return time;
};
In the above example it simply takes the two input variables, the distance and the speed,
and uses both of them to calculate the time variable. Then the keyword return is used
to return the value.
While calling the function included with one of a WMLScript standard libraries,
the library name should be included with a function call. Consider for an example,
to call a String library�s length() function, we make useof the following syntax: