My first usefull snippet here on Hawkee, I guess!
It gives you a random output of the input string
Usage:
/randomize [-tsn] [amount of times] [till what number] [string]
or $Randomize(-ts [amount of times] [till what number] [string])
[size=19]The randomize alias has multiply switches, I will try to explain them:[/size]
If no switch given
The script will randomize the string 1 to input. Example: $Randomize(5) -> 4 5 2 3 1
If the -t switch supplied
The script will randomize the string to $2. But it will do it $1 times. Example: $Randomize(-t 3 10) -> 5 8 7 4 10 2 3 9 6 1~4 9 8 6 10 1 7 5 3 2~3 5 8 4 10 1 7 6 9 2
If the -s switch supplied
The script will randomize the string you've given. Example: $randomize(-s hello i am dani l11 who are you?) -> dani who i are am you? hello l11
If the -s and t switch supplied
The script will randomize the string you've given $2 times. Example: $randomize(-st 5 hello i am dani l11 who are you?) -> dani l11 are i hello you? who am~you? who hello am l11 are dani i~who i dani are you? l11 hello am~hello dani l11 are you? i am who~am are i l11 who hello you? dani
If the -t and n switch supplied
Instead of seperating the multiply random strings with a ~, it will now echo them each on a new line. Example:
/randomize -tn 4 15 ->
1 4 2 5 8 12 10 6 13 9 7 11 3 15 14
5 14 15 6 8 9 10 3 2 13 1 12 4 11 7
3 1 8 15 11 2 7 5 12 10 4 9 14 6 13
12 5 7 11 6 2 15 10 14 8 1 13 4 3 9
The same goes with the s switch; Example:
/randomize -tns 4 hello i am still dani l11 ->
dani l11 still i am hello
dani i still hello l11 am
dani am still hello l11 i
l11 i dani am still hello
If you have any questions, feel free to ask.
alias randomize {
;randomize -s list = You supplied the list it needs to randomize itself
;randomize -st NUM list = You supplied the list it needs to randomize itself. Do it NUM times.
;randomize -t NUM X = Randomize numbers 1 to X NUM times.
var %ret = $iif($isid,return,echo -a)
if (%ret == return) tokenize 32 $1-
noop $regex($1,/^-([ts]|tn|[ts][ts]n?|[ts]n?[ts]|n?[ts][ts])$/)
var %tr = $regml(1)
if (%tr) tokenize 32 $2-
if (*t*t* iswm %tr) || (*s*s* iswm %tr) { %ret Invalid syntax | return }
if (n isin %tr) && (t !isin %tr) { %ret Invalid syntax | return }
if (n isin %tr) { var %newline = ja | var %tr = $remove(%tr,n) }
if ($1 !isnum && s != %tr) { %ret Invalid syntax | return }
if (t == %tr) && ($1 !isnum || $2 !isnum) { %ret Invalid syntax | return }
if (!%Tr) || (t == %tr) {
var %x = 1,%numto = $iif(!%Tr,$1,$2)
while (%x <= %numto) {
var %list = %list %x
inc %x
}
}
if (s isin %tr) var %list = $iif(t isin %tr,$2-,$1-)
var %blist = %list
var %yz = 1
while (%yz <= $iif(t isin %tr,$1,1)) {
var %list = %blist,%rstring
while ($gettok(%list,1,32)) {
var %rnum = $r(1,$numtok(%list,32))
var %rstring = %rstring $gettok(%list,%rnum,32)
var %list = $deltok(%list,%rnum,32)
}
if (%newline) && (%ret == echo -a) {
echo -a %rstring
}
else var %oput = %oput $+ ~ $+ %rstring
inc %yz
}
if (!%newline) || (%ret != echo -a) %ret $right(%oput,-1)
}
you know with some slight changes in this script the fist switch (-t) could be a separate script for a password generator.
the last switch (-tn) could be a separate script for a word jumble game.
switch (-st) could be made into a flood script. with different types (notice flooding, pm flooding).
I think its cool how you have figured out the different ways to use the switches.