In
the following sections, we will look at some of the more commonly
used functions in the Lang standard library.

Generating Random
Numbers: seed() and random() Functions

The
seed() and random()
functions of the Lang standard library are used to initialize the
random number generator and to generate random numbers respectively.
The syntax of the seed()
function is:

Lang.seed(numeric_value);

If
numeric_value < 0, the
value used to initialize the random number generator will be
determined by the mobile device randomly. In most cases, you will
specify the initialization value this way since it ensures the random
number sequence generated will not be repeated.

If
numeric_value >= 0,
numeric_value will be
used to initialize the random number generator.

If
no error occurs, the seed()
function returns an empty string, otherwise it returns an invalid
value.

Now
let's look at the random()
function. Its syntax is:

Lang.random(numeric_value);

The
random() function returns a random integer in the range 0 to
numeric_value if everything works fine, otherwise it returns
an invalid value.

The
following WMLScript example illustrates how to generate random
numbers:

What do you think about this web page? It is very helpful. It is helpful, but some information I wanted is missing. It is not helpful. It has broken links. It has typos / grammatical mistakes. It has incorrect information. Others

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Due to the amount of messages we received, we may not be able to reply to all messages.