FUNCTION:  Lang.abs

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.
The mandatory value parameter can be any positive or negative single-precision floating-point number or any positive or negative integer number (including zero). The floating-point number must reside on or between the largest number and the smallest nonzero number supported by the browser. These boundary values can be determined using the Float.maxFloat and Float.minFloat functions.
Code for AbsExample.wml
<?xml version="1.0"?>

<card id="card1">
   abs example
   <do type="accept">
      <go href="AbsExample.wmls#findabs()" />

<card id="card2">
   original number = $(number)
   <br />
   absolute number = $(absnumber)


Code for AbsExample.wmls
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);

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information