Returns a random positive integer.
The Lang.random function generates and
returns a pseudo-random positive integer number that is greater than or
equal to zero and less than or equal to the given value
parameter (i.e., the value parameter sets the upper boundary for
the pseudo-random number).
The actual
pseudo-random number that is generated will be browser dependent.
Unfortunately, many random number generators tend to generate the same
repetitive sequence of 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>
random
example
</p>
<do type="accept">
<go
href="RandomExample.wmls#findrandom()" />
</do>
</card>
<card id="card2">
<p>
random number = $(randomnumber)
</p>
</card>
</wml>Code for RandomExample.wml
extern function findrandom()
{
var result = Dialogs.prompt("Enter number",
"");
var randnum = Lang.random(result);
WMLBrowser.setVar("ramdomnumber",
randnum);
WMLBrowser.go("RandomExample.wml#card2");
};
Code for RandomExample.wmls