Converts a given value to a string.
The
String.toString function takes the given value and converts it
into a string. The value can be a boolean, fixed-point number,
floating-point number, or even a string. The converted value is
returned. If the value is invalid, then this function returns
invalid.
Once the value is converted,
you can use the String.trim function to remove all leading and
trailing white space. You can also use the String.squeeze to
remove extra white spaces between characters and elements.
<?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>
toString
example
</p>
<do type="accept">
<go
href="ToStringExample.wmls#findtostring()" />
</do>
</card>
<card id="card2">
<p>
value = $(value)
<br />
string =
$(strng)
</p>
</card>
</wml>Code for ToStringExample.wml
extern function
findtostring()
{
var val =
Dialogs.prompt("Enter a value", "");
var
str = String.toString(val);
WMLBrowser.setVar("strng", str);
WMLBrowser.setVar("value", val);
WMLBrowser.go("ToStringExample.wml#card2");
};
Code for ToStringExample.wmls