String.squeeze
String.trim
FUNCTION: String.toString
String.toString
(value)
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.
The mandatory
value
parameter can be any combination of zero or more characters (letters, numbers, decimal points, etc.) and white spaces. If the value is an empty string, an empty string is returned.
Code for ToStringExample.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>
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.wmls
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");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information