egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A proc that generates random digits

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 928

PostPosted: Thu Sep 22, 2022 7:54 am    Post subject: A proc that generates random digits Reply with quote

greetz gentz,

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

for example:
Quote:
100-350


or

Quote:
10 50 100 200 250


and so on
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1021
Location: France

PostPosted: Thu Sep 22, 2022 8:30 am    Post subject: Reply with quote

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

If you want a number between 100 and 250:
Code:
set min 100
set max 100
set myrand [expr {$min + round(rand()*($max-$min))}]


If you want a random number from a list:
Code:
set items {10 25 50 75 100}
set myrand [lindex $items [rand [llength $items]]]

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 928

PostPosted: Thu Sep 22, 2022 8:42 am    Post subject: Reply with quote

thanks CrazyCat
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber