FUNCTION:  Lang.random

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"?>

<card id="card1">
   random example
   <do type="accept">
      <go href="RandomExample.wmls#findrandom()" />

<card id="card2">
   random number = $(randomnumber)


Code for RandomExample.wmls
extern function findrandom()
   var result = Dialogs.prompt("Enter number", "");
   var randnum = Lang.random(result);
   WMLBrowser.setVar("ramdomnumber", randnum);

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