Functions

random

Supported By

Syntax

[the] random of factor

random ( expression )

Factor and expression yield integers.

Description

The random function returns a random integer between 1 and the specified integer, inclusive. If the specified integer is less than 1, the random function always returns 1.

Script

The following example draws 10 unique random numbers between 1 and 100:

on drawRandom
  put empty into randomList
  repeat until the number of items in randomList is 10
    get random of 100
    if (the itemdelimiter & it & the itemdelimiter) is not in ¬
        (the itemdelimiter & randomList & the itemdelimiter) then
      put it & the itemdelimiter after randomList
    end if
  end repeat
  delete last char of randomList
  put randomList
end drawRandom

See Also

randomDecimal, randomRange