Returns the specified portion of a string.
The
String.elementAt function finds and returns the string element
at the given index position in the given string.
This function treats a string as an array composed of
elements delimited by a separator that is composed of one or more
specified characters (including white space). The first index position
is numbered zero and the last index position is the total number of the
elements minus one. The total number of elements in the string can be
found by using the String.elements function.
If the string is empty, the empty string "" is
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>
elementAt
example
</p>
<do type="accept">
<go
href="ElementAtExample.wmls#findelementat()" />
</do>
</card>
<card id="card2">
<p>
string = $(strng)
<br />
index =
$(index)
<br />
separator = $(separator)
<br />
element
= $(element)
</p>
</card>
</wml>Code for ElementAtExample.wml
extern function
findelementat()
{
var str =
Dialogs.prompt("Enter a string", "Hello wireless world!");
var ind = Dialogs.prompt("Enter an index",
"1");
var sep = Dialogs.prompt("Enter a
separator", " ");
var elem = String.elementAt(str, ind, sep);
WMLBrowser.setVar("strng", str);
WMLBrowser.setVar("index", ind);
WMLBrowser.setVar("separator", sep);
WMLBrowser.setVar("element", elem);
WMLBrowser.go("ElementAtExample.wml#card2");
};
Code for ElementAtExample.wmls