Sets the value for the named variable.
The WMLBrowser.setVar
function sets the named variable to have the given value and returns a
boolean value. A true is returned if the set is successful. A
false is returned if the set is not successful.
The syntax of both the name and the value
must be correct or invalid will be returned.
<?xml version="1.0"?>
<!DOCTYPE wml
PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
setVar
example
</p>
<do type="accept">
<go
href="SetVarExample.wmls#findsetvar()" />
</do>
</card>
<card id="card2">
<p>
return 1 = $(bool1)
<br />
return 2
= $(bool2)
<br />
$(varname) = $(varvalue);
</p>
</card>
</wml>Code for SetVarExample.wml
extern function findsetvar()
{
var nam = Dialogs.prompt("Enter the name",
"");
var val = Dialogs.prompt("Enter the
value", "");
var boo1 = WMLBrowser.setVar("varname", nam);
var boo2 = WMLBrowser.setVar("varvalue", val);
WMLBrowser.setVar("bool1", boo1);
WMLBrowser.setVar("bool2", boo2);
WMLBrowser.go("SetVarExample.wml#card2");
};
Code for SetVarExample.wmls