Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference > Siebel eScript Commands > The Math Object >
Math.random() Method
This function returns a pseudo-random number between 0 and 1.
Syntax
Math.random()
Returns
A pseudo-random number between 0 and 1.
Usage
This function generates a pseudo-random number between 0 and 1. It takes no arguments. Where possible, it should be used in place of the Clib.rand() method. The Clib.rand() method is to be preferred only when it is necessary to use Clib.srand() to seed the Clib random number generator with a specific value.
Example
This example generates a random string of characters within a range. The Math.random() function is used to set the range between lowercase a and z.
function Test_Click ()
{
var str1 = "";
var letter;
var randomvalue;
var upper = "z";
var lower = "a";upper = upper.charCodeAt(0);
lower = lower.charCodeAt(0);for (var x = 1; x < 26; x++)
{
randomvalue = Math.round(((upper - (lower + 1)) *
Math.random()) + lower);
letter = String.fromCharCode(randomvalue);
str1 = str1 + letter;
}TheApplication().RaiseErrorText(str1);
}See Also
Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference Published: 18 April 2003 |