Sample code for 30+ languages & platforms
Tcl

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set success 0

set fortuna [new_CkPrng]

# Generate random integers between 12 and 24 inclusive

for {set i 0} {$i <= 100} {incr i} {
    puts [CkPrng_RandomInt $fortuna 12 24]
}

delete_CkPrng $fortuna