O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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";

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required