String.isEmpty
String.elements
FUNCTION: String.length
String.length
(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).
The mandatory
string
parameter can be any string containing zero or more of any combination of characters (including white spaces). This parameter can also be an empty string.
Code for LengthExample.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>
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.wmls
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");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information