FUNCTION:  Lang.seed

The Lang.seed function is used to initialize the pseudo-random number generating sequence. This is referred to as seeding the random number sequence. Unfortunately, many random number generators tend to generate the same repetitive sequence of numbers. The purpose of the seed is to make the generated number more random.
Be aware that the actual pseudo-random number that is generated will be browser dependent.
The mandatory value parameter can be any positive or negative integer number (including zero) recognized by the browser. If a floating-point number is provided, only the integer portion will be used.
  • If the seed is zero or a positive integer, then the provided seed value is used and a repeatable sequence of pseudo-random numbers will be generated.

  • If the seed is a negative integer, then the provided seed value is not used and, instead, a system-generated initialization value will be used.

    Code for SeedExample.wml
    <?xml version="1.0"?>

    <card id="card1">
       seed example
       <do type="accept">
          <go href="SeedExample.wmls#findseed()" />

    <card id="card2">
       seed = $(myseed)
       <br />
       random number = $(randomnumber)


    Code for SeedExample.wmls
    extern function findseed()
       var myseed = Dialogs.prompt("Enter seed number", "-6");
       var randnum = Lang.random(1000);
       WMLBrowser.setVar("myseed", myseed);
       WMLBrowser.setVar("ramdomnumber", randnum);

    Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
    Trademark Information