Java Reference
In-Depth Information
platform used in combination with WML to provide client-side procedural logic. Like WML,
WMLScript is compiled through a WAP gateway into binary form to provide intelligence to
mobile clients. This section will be used to present the WMLScript language and its libraries; it
concludes with an example illustrating the use of WMLScript to perform client-side validation.
Calling WMLScript from WML
For a WMLScript function to be called from WML, the function must be declared within its
source file using the extern keyword. The syntax for calling a function is as follows:
sourcefile.wmls#functionname(arguments)
WML calls the WMLScript function through a hyperlink such as the <a></a> anchor tag or the
<go></go> action tag. For example, a fictional WMLScript function call could be triggered
from an anchor tag such as:
<a href=”sourcefile.wmls#functionname(arguments)”>Click Here!</a>
Language Basics
WMLScript uses virtually the same syntax as JavaScript. Some of the basic language rules
include
All statements must end with a semicolon (;)
Variables are declared using the var keyword (for example, var counter=0; )
Multiline comments are surrounded by /* */ ; single-line comments begin with //
The language is case sensitive
All WMLScript code must live inside a function
The language is comprised of six standard libraries: Lang , Float , String , URL ,
WMLBrowser , and Dialogs
No run-time or compile-time type checking is done
The language supports five internal data types: Boolean , Integer , Floating-point ,
String , and Invalid
WMLScript functions feature the following syntax:
function new_function(parameters)
{
code body
}
To return a value from a function, use the return keyword.
Search WWH ::




Custom Search