Returns the length of the string.
The
String.length function returns the integer length of a given
string. If the string is an empty string, a zero is returned.
Note that you can use the String.isEmpty
function to determine if a string is empty (i.e., has zero length).
<?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>
length
example
</p>
<do type="accept">
<go
href="LengthExample.wmls#findlength()" />
</do>
</card>
<card id="card2">
<p>
string = $(strng)
<br />
length =
$(result)
</p>
</card>
</wml>Code for LengthExample.wml
extern function
findlength()
{
var str =
Dialogs.prompt("Enter a string", "");
var
len = String.length(str);
WMLBrowser.setVar("strng", str);
WMLBrowser.setVar("result", len);
WMLBrowser.go("LengthExample.wml#card2");
};
Code for LengthExample.wmls