6. Calling WMLScript Functions
6.1. Calling a Function Located in the Same WMLScript File
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)
{
...
}
Previous Page | Page 8 of 71 | Next Page |
- 1. WMLScript Introduction
- 2. Hello World WMLScript Example
- 3. Compiling WMLScript Code
- 4. WMLScript Language Rules
- 5. Defining WMLScript Functions
- 6. Calling WMLScript Functions
- 7. WMLScript Variables
- 8. WMLScript Data Types
- 9. WMLScript Variables Vs WML Variables
- 10. Passing Arguments to Functions By Value and By Reference
- 11. WMLScript Operators
- 12. WMLScript Conditional Statements
- 13. WMLScript Looping Statements
- 14. WMLScript Standard Libraries Overview
- 15. WMLScript WMLBrowser Standard Library
- 16. WMLScript Dialogs Standard Library
- 17. WMLScript String Standard Library
- 18. WMLScript Float Standard Library
- 19. WMLScript Lang Standard Library
- 20. WMLScript URL Standard Library
- 21. WMLScript Example: Validating Form Data