WMLScript » Lang » Lang.min

Syntax:
Lang.min(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 minimum of two numbers.

The Lang.min function compares the given numbers and then returns the smaller 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>
   mins example
   </p>
   <do type="accept">
      <go href="MinExample.wmls#findmin()" />
   </do>
</card>

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

</wml>
Explanation:

Code for MinExample.wml

Language(s): WML
Code:
extern function findmin()
{
   var result1 = Dialogs.prompt("Enter 1st number", "");
   var result2 = Dialogs.prompt("Enter 2cd number", "");
   var minnum = Lang.min(result1, result2);
   WMLBrowser.setVar("number1", result1);
   WMLBrowser.setVar("number2", result2);
   WMLBrowser.setVar("minnumber", minnum);
   WMLBrowser.go("MinExample.wml#card2");
};
Explanation:

Code for MinExample.wml

Language(s): WML

See Also: