Calls to Other Script Units

To call a function in another file, you must specify the external file in the call:

            file-identifier#function-name (argument-list)

The function name and argument list are the same as before. The file-identifier references a URL via a name set up with a url pragma. (This pragma is described in the next section.) The file-identifier name itself follows the same rules as variable names. Examples of external function calls include:

mathlibrary#factorial (6)
arraylibrary#sort (array)
netlib#check_email_address (addr)

The url pragma

The url pragma that names the external file looks like this:

use url file-identifier url-string;

The file-identifier is the name used in the external function calls. It follows the same rules as variable names. You can have a file-identifier with the same name as either a WMLScript function or a variable, because all three use different namespaces.

The url-string is a normal WMLScript string literal. Its contents must be a valid URL. This URL may be relative or absolute: relative URLs are resolved against the URL used to fetch the current script module. (URL resolving is discussed in Appendix A.) This URL must not contain a # character, so it can’t specify a fragment.

Here are some examples:

use url netlib "http://wap.net/lib/netlib.wmlsc";
use url test "test.wmlsc";
use url example "/script/example.wmlsc";

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.