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 

generate random alphabetical chars between 5 and 10

 
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: 941

PostPosted: Mon Sep 07, 2020 2:57 pm    Post subject: generate random alphabetical chars between 5 and 10 Reply with quote

hey there gents,

i was wondering what would be the proper way to generate random a-zA-z
chars between 5 and 10

like

HgfdH
Qaygfff
Xwqyttoooo

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


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Sep 07, 2020 6:39 pm    Post subject: Reply with quote

You mean an adaptation of the script requested @ http://forum.egghelp.org/viewtopic.php?p=108557 ?

Code:
# usage : randString <min> <max>
proc randString { {min 1} {max 8} } {
   set chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
   set size [expr {int(rand()*($max-$min+1)+$min)}]
   set range [string length $chars]
   set txt ""
   for {set i 0} {$i < $size} {incr i} {
      set pos [expr {int(rand()*$range)}]
      append txt [string index $chars $pos]
   }
   return $txt
}

If min is not defined, it's between 1 and 8 chars.
If min is defined, between <min> and 8 chars long (min must be lower than 8, I didn't check the values)
If min and max are defined, it's between <min> and <max> chars long (idem)
_________________
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: 941

PostPosted: Mon Sep 07, 2020 8:05 pm    Post subject: Reply with quote

Oh i totally forgot about that post thanx 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