WMLScript » Lang » Lang.isInt

Syntax:
Lang.isInt(value)
value
The value parameter is the string value that you need converted into an integer.

Determines if a value can be converted to an integer.

The Lang.isInt function returns a boolean value that indicates whether a string value can be converted into an integer number using the Lang.parseInt function. A true signifies that you can convert. A false signifies that you cannot convert.

The companion Lang.isFloat function returns a boolean value that indicates whether a string value can be converted into a floating-point number using the Lang.parseFloat function.

Examples

Code:
<?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>
   isInt example
   </p>
   <do type="accept">
      <go href="IsIntExample.wmls#findisint( )" />
   </do>
</card>

<card id="card2">
<p>
   can convert = $(isinttest)
</p>
</card>

</wml>
Explanation:

Code for IsIntExample.wml

Language(s): WML
Code:
extern function findisfloat( )
{
   var str = Dialogs.confirm("Enter a string", "");
   var result = Lang.isInt(str);
   WMLBrowser.setVar("isinttest", result);
   WMLBrowser.go("IsIntExample.wml#card2");
};
Explanation:

Code for IsIntExample.wmls

Language(s): WML

See Also: