|
Newsletters
|
|
|
|
|
WMLScript Reference
WMLScript Reference
WMLScript > Lang > seed()
seed() - The seed Function
Usage: seed(value)
Description: Initialises the pseudo-random number sequence and returns an empty string. If the value is zero or a positive integer then the give value is used for initialisation, otherwise a random, system dependent initialisation value is used. A seed value of greater than or equal to zero results in a repeatable sequence of pseudo-random numbers. A seed value of less than zero results in a non-repeatable sequence of random numbers.
If the value is of type floating-point, Float.int() is first used to calculate the actual integer value. If the value is non-numeric, invalid is returned and the current seed is unchanged.
Example:var a = Lang.seed(123); // a = ""
var b = Lang.random(20); // b = 0..20
var c = Lang.seed("seed"); // c = invalid (random seed left unchanged)
Lang.seed(7);
var a = Lang.rand(10); // a = 4(perhaps)
Lang.seed(7);
var b = Lang.rand(10); // b = 4(perhaps, but same as a)
Lang.seed(-1);
var c = Lang.rand(10); // c = 6(perhaps)
Lang.seed(-1);
var d = Lang.rand(10); // d = 1(perhaps, but not necessarily the same as c)
Bookmark this page
|
|