WMLScript Reference

[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Chapter 6 - Functions
Section 21 out of 34 total sections , Section 3 out of 3 sections in this chapter


Function Calls

Function calls return a value, such as the result of a calculation. The way a function is called depends on where the call (target) function is declared. The following sections describe three function calls supported by WMLScript 1.1:



Local Script Functions


Definition

A function that is declared and called in the same file.


Examples

The following is an example of a local script function:

function test2 (param) {
return test1 (param+1);
};  

function test1 (val) {
return val*val;
};  


Comments

Local script functions can be called simply by providing the function name and a comma-separated list of arguments. The number of arguments must match the number of parameters accepted by the function.

A local script function can be called before it has been declared.



External Functions


Definition

A function that is declared in an external file.


Examples

The following is an example of an external function:

use url OtherScript "http://www.host.com/script";  
 
function test3(param) {
    return OtherScript#test2(param+1);
};  


Comments

The external function call must be prefixed with the name of the external file.

You must use the use url pragma to specify the external file. This pragma maps the external unit to a name that can be used within the function declaration. This name and the hash symbol (#) are used to prefix the standard function call syntax.



Library Functions


Definition

A function that calls a WMLScript 1.1 standard library function.


Examples

The following is an examle of a library function:

function test4(param) {
    return Float.sqrt(Lang.abs(param)+1);
};  


Comments

You can call a library function by prefixing the function name with the name of the library and the dot symbol (.). In the example above, function abs is prefixed by library Lang.


[Cover] [Previous Section] [Next Section] [Index]


Part Number DKWS-41-002, UP.SDK Release 4.1, December 2000

Copyright © 1994-2000 Openwave Systems Inc. All rights reserved.
Please send comments and questions to sdk-doc-comments@openwave.com.