This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

A proc that generates random digits

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

A proc that generates random digits

Post by simo »

greetz gentz,

i wanted to use random digits in range or specific digits to use in certain other tcls

for example:
100-350
or
10 50 100 200 250
and so on
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I don't really understand what you're asking for.

If you want a number between 100 and 250:

Code: Select all

set min 100
set max 100
set myrand [expr {$min + round(rand()*($max-$min))}]
If you want a random number from a list:

Code: Select all

set items {10 25 50 75 100}
set myrand [lindex $items [rand [llength $items]]]
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks CrazyCat
Post Reply