FUNCTION:  WMLBrowser.setVar

WMLBrowser.setVar(name, value)
 
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.
 
The mandatory name parameter is the name of the variable. Note in the example, how the name is enclosed within a pair of double quotation marks.
 
The mandatory value parameter is the value to be assigned to the named variable. This parameter can be a named variable with an assigned value or you can enclose the value within a pair of double quotation marks.
 
Code for SetVarExample.wml
<?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.wmls
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");
};


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information