Returns the absolute value.
The Lang.abs function returns the
absolute value of a specified number. If the number is a
floating-point, then an absolute floating-point number is returned. If
the number is an integer, then an absolute integer will be returned.
Several functions in the Float Library
can also be used to manipulate numbers.
<?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>
abs
example
</p>
<do type="accept">
<go
href="AbsExample.wmls#findabs()" />
</do>
</card>
<card id="card2">
<p>
original number = $(number)
<br />
absolute
number = $(absnumber)
</p>
</card>
</wml>
Code for AbsExample.wml
extern function
findabs()
{
var mydefault =
"-71.348";
var result =
Dialogs.prompt("Enter any number", mydefault);
var absnum = Lang.abs(result);
WMLBrowser.setVar("number", result);
WMLBrowser.setVar("absnumber", absnum);
WMLBrowser.go("AbsExample.wml#card2");
};
Code for AbsExample.wmls