WMLScript Variable Naming Conventions

Preferences - Do not show ads

In WMLScript, the naming conventions of variables are the same as that of functions. Variable names are case-sensitive and they cannot be the same as WMLScript reserved words and keywords. The first character of a variable name has to be a letter or an underscore. The rest of the characters can be letters, numbers, or underscores.


Scope and Lifetime of WMLScript Variables

In WMLScript, after you have declared a variable in a function, you can modify or read the value of the variable until the function ends. The variable will be destroyed when the execution of the function is finished. Hence, the scope of a WMLScript variable is from the place where it is declared to the end of the function, and the lifetime of it starts from the time it is declared to the time when the function finishes. This means you can use the same variable name in different WMLScript functions, since the scope of a variable does not go outside the function where the variable is declared.

Note that block statements have no effect in variable scoping (a block statement is a group of statements that are enclosed within {}). For example, the following code is correct in WMLScript:


function wmlscript_func()
{
  {
     var wmlscript_variable;
  }
  {
     wmlscript_variable = "Welcome to our WMLScript tutorial";
  }
  wmlscript_variable = "WMLScript Tutorial";
}


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

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