Welcome to Developer's Home Wednesday, April 16, 2014
Home - DevelopersHome.com

Calling WMLScript Functions


Calling a Function Located in the Same WMLScript File


Preferences - Do not show ads

It is straightforward to call a function located in the same WMLScript file. You just need to type the name of the function you want to call, like this:

(Suppose the definitions of main_function(), wmlscript_function1() and wmlscript_function2() are located in the same file.)


function main_function()
{
...
  wmlscript_function1();
  wmlscript_function2(arg1, arg2);
...
}


In the above WMLScript example, wmlscript_function1() and wmlscript_function2() are called from main_function(). Arguments are included inside the parentheses. If the function to be called does not require any arguments, you still need to include the parentheses.

In some programming languages such as C++, the definition of the function to be called must be placed before that of the calling function. This is not required in WMLScript. The order of functions in a WMLScript file does not have any effect. For example, the following WMLScript code:


function wmlscript_function1()
{
...
}

function wmlscript_function2(arg1, arg2)
{
...
}

function main_function()
{
...
  wmlscript_variable1 = wmlscript_function1();
  wmlscript_variable2 = wmlscript_function(arg1, arg2);
...
}


is equivalent to the code below:


function main_function()
{
...
  wmlscript_variable1 = wmlscript_function1();
  wmlscript_variable2 = wmlscript_function(arg1, arg2);
...
}

function wmlscript_function1()
{
...
}

function wmlscript_function2(arg1, arg2)
{
...
}


Page 8 of 71 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top
Custom Search

Feedback Form (Expand)

What do you think about this web page?






WMLScript Tutorial Table of Contents WMLScript Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page