Generate Random Number

The easiest way to generate a random number is to use java.util.Random. Create the object and call the nextInt(int n) method. It will return a random integer >= 0 and < n.

   Local JavaObject &oRandom;
   Local integer &iNumber, &iMaxInt;

   &iMaxInt = 10;
   &oRandom = CreateJavaObject("java.util.Random");

   /* &iNumber will be an integer between 1 and 10 */
   &iNumber = &oRandom.nextInt(&iMaxInt) + 1;

Refrences

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License