Page 155 - DCAP512_WAP_AND_WML
P. 155
Unit 11: Using WML Script
Semicolons mark the ends of statements. Notes
Comments are marked with “//”.
Task In a group of four analyze why do WML scripts need to be compiled into byte code
before they can be run on a WAP browser?
11.1.2 What are the WML Script Syntax Rules?
WML Script Functions
An “executable” file in WML Script is called a function
A function is
An ordered set of language statements
Modeled to perform a task
Selected with the wmls filename extension
Stored on the application server
Executed on the device
Referenced from WML, not contained in it
Accessed by URL, like a deck or card
Notes A WMLScript function is a named part of the WMLScript compilation unit that you
can call to perform a specific set of statements and to return a value.
The following section describe how you can declare and use WMLScript functions.
Declaration
You can use the function declaration to declare a WMLScript function name (Identifier) with the
optional parameters (FormalParameterList) and a block statement that is executed when the
function is called. All functions have the following characteristics:
Function declaration cannot be nested.
Function names must be unique within one compilation unit.
All parameters to functions are passed by value.
Function calls must pass exactly the same number of arguments to the called function as
specified in the function declaration.
Function parameters behave like local variables that have been initialized before the
function body (block of statement) is executed.
A function always returns a value. By default, it is an empty string (“ “). However, you can
use a return statement to specify other return values.
LOVELY PROFESSIONAL UNIVERSITY 149