| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Sep 07, 2020 2:57 pm Post subject: generate random alphabetical chars between 5 and 10 |
|
|
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 |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Mon Sep 07, 2020 6:39 pm Post subject: |
|
|
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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Sep 07, 2020 8:05 pm Post subject: |
|
|
| Oh i totally forgot about that post thanx crazycat |
|
| Back to top |
|
 |
|