In WMLScript, function declarations include a function name with optional parameters and a block statement that is executed when the function is called.
All functions have the following characteristic:
Function declarations cannot be nested
Function names must be unique within each script file
All parameters to functions are passed by value
Function calls must pass exactly the same number of arguments to the called function as specified in the function declaration
Function parameters behave like local variables that have been initialized before the function body (block of statements) is executed
A function always returns a value. By default it is an empty string (""). Use a return statement to specify other return values.
You can use the extern keyword to make a function available to an outside file.
function currencyConverter(currency, exchangeRate) {
return currency*exchangeRate;
}
extern function testIt() {
var USD = 10;
var FIM = currencyConverter (USD, 5.3);
}