6.2. Calling a Function
Located in a Different WMLScript File
call a function located in a different WMLScript file, you have to
declare that WMLScript file at the very beginning of your code using
the "use url" statement, which has the following form:
url identifying_name "url_of_the_wmlscript_file";
is a name you associated to the external WMLScript file. This name
will be used to refer to the external WMLScript file.
is the URL of the external WMLScript file. The URL can be in absolute
or relative form.
you have declared the external WMLScript file, you can call a
function located in that file by:
let's see an example that can help you understand what we are talking
about better. Let's say the wmlscript_1.wmls file contains the
following function wmlscript_function():
return "Welcome to our
we want to call wmlscript_function() in the main_function()
function of another WMLScript file (wmlscript_2.wmls)
that is located in the same directory as wmlscript_1.wmls. To
do this, we can write something like this:
url Script1 "wmlscript_1.wmls";
both files wmlscript_1.wmls and wmlscript_2.wmls are
located in the same directory, we just need to use the file name as
the URL in the "use url" statement.
that the function definition of wmlscript_function() starts
with the extern keyword. The extern keyword is required
here. It specifies that wmlscript_function() is allowed to be
called from outside wmlscript_1.wmls.
Feedback Form (ExpandCollapse)