Java Reference
In-Depth Information
L ISTING 24.3
Continued
function getString(var str)
{
//Set the variable in the browser environment
WMLBrowser.setVar(“txtInput”, str);
//Now transfer focus to the length_output card
WMLBrowser.go(“#input_output”);
}
/*
* This function accepts a string and returns its length
*/
function getLength(var str)
{
var len = String.length(str);
//Now set the variable in the browser environment
WMLBrowser.setVar(“strLength”, len);
//Now transfer focus to the length_output card
WMLBrowser.go(“#length_output”);
}
Listing 24.4 represents the source code for WMLScriptExample.wml —the WML file used to
execute the functions defined in Listing 24.3.
L ISTING 24.4
WMLScriptExample.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=”welcome” title=”WMLScript Example”>
<p>
Welcome to the WMLScript example! Select from
one of these tests:<br/><br/>
<a href=”WMLScriptExample.wmls#setVar()”>Setvar Test</a><br/>
<a href=”#input”>Input Test</a><br/>
<a href=”#length”>Length Test</a><br/>
</p>
</card>
Search WWH ::




Custom Search