Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

WMLScript Language Rules

Added 28 Jul 2008

WMLScript is developed based on ECMAScript, which is the standardized version of JavaScript. Thus, WMLScript's language rules are very similar to that of JavaScript.


Semicolons at the End of WMLScript Statements

A semicolon is required to end a statement in WMLScript. This is the same as C++ and Java. Note that JavaScript does not have such requirement. In JavaScript, semicolons are optional. The following code is taken from the earlier "Hello World" example. You can see that the two WMLScript statements in this function are ended with semicolons.


extern function helloWorld()
{
  WMLBrowser.setVar("message", "Hello World. Welcome to our WMLScript tutorial.");
  WMLBrowser.refresh();
}


Whitespaces in WMLScript

Except in string literals, WMLScript ignores extra whitespaces like spaces, tabs and newlines. Hence, the code in the earlier "Hello World" example can be typed in the following way and the result will remain the same:


extern     function helloWorld()
{
                    WMLBrowser.setVar(
"message",
   "Hello World. Welcome to our WMLScript tutorial.");
         WMLBrowser.refresh();
}


Case Sensitivity in WMLScript

The WMLScript language is case-sensitive. For example, a WMLScript function with the name WMLScript_Function is different from wmlscript_function. So, be careful of the capitalization when defining or referring to a function or a variable in WMLScript.