7.2. WMLScript Variable Naming Conventions
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.
7.3. 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";
}
Previous Page | Page 12 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