The var statement is used to create a named variable. This refered
to as initializing the variable. At the same time you can also set a value
(including the empty string) for the variable, or, by default, allow the
variable to assume the value of the empty string "" and assign a value
at a later time. Indeed, after a variable has been created, you can change
its value whenever you wish and as many times as you wish.
A named variable is said to have a scope. By scope, we mean where the
named variable will be recognized by the program. In WMLS, the scope of
a variable is limited to inside the function in which the var is
declared. However, you can use the WMLBrowser.setVar function to
set a named variable with a value that can be displayed in a .wml program.
The name of the variable is a string that is composed of characters that
are legally recognized by WMLS. The name must be unique within the function.
Clearly you can not use the names of the WMLScript libray functions, operators,
or statements as a variable name since they are considered reserved words.
Code for ForExample.wml
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
Code for ForExample.wmls
extern function findfor()
var hoo = "";
var myfavoritenum =
var name = "Fred";
for(var count=0; count<99;
var str = "My pet jaguar
is named Oztotl.";
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.