FUNCTION: Lang.random
Lang.random(value)
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.
The mandatory value parameter can be any positive floating-point
number or any positive integer number (including zero) recognized by the
browser. Note that zero always returns zero. If a floating-point number
is provided, only the integer portion will be used.
Code for RandomExample.wml
<?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.wmls
extern function findrandom()
{
var result = Dialogs.prompt("Enter number", "");
var randnum = Lang.random(result);
WMLBrowser.setVar("ramdomnumber", randnum);
WMLBrowser.go("RandomExample.wml#card2");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
|