WMLScript » Lang » Lang.max

Syntax:
Lang.max(value1, value2)
value1
The mandatory value1 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. The integer number must reside on or between the largest positive integer and the largest negative integer supported by the browser. These boundary values can be determined by using the Lang.maxInt and Lang.minInt functions.
value2
The mandatory value2 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. The integer number must reside on or between the largest positive integer and the largest negative integer supported by the browser. These boundary values can be determined by using the Lang.maxInt and Lang.minInt functions.

Returns the maximum of two numbers.

The Lang.max function compares two given numbers and then returns the larger value. If the two numbers prove to be equal, the first number is selected. The value and type (floating-point or integer) of the selected number is not changed.

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>
   max example
   </p>
   <do type="accept">
      <go href="MaxExample.wmls#findmax()" />
   </do>
</card>

<card id="card2">
<p>
   1st number = $(number1)
   <br />
   2cd number = $(number2)
   <br />
   maximum number = $(maxnumber)
</p>
</card>

</wml>
Explanation:

Code for MaxExample.wml

Language(s): WML
Code:
extern function findmax()
{
   var result1 = Dialogs.prompt("Enter 1st number", "");
   var result2 = Dialogs.prompt("Enter 2cd number", "");
   var maxnum = Lang.max(result1, result2);
   WMLBrowser.setVar("number1", result1);
   WMLBrowser.setVar("number2", result2);
   WMLBrowser.setVar("maxnumber", maxnum);
   WMLBrowser.go("MaxExample.wml#card2");
};
Explanation:

Code for MaxExample.wmls

Language(s): WML

See Also: