Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

Randomize alias

Recommended Posts

  • Administrators

Randomize alias

 

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])

 

 

The randomize alias has multiply switches, I will try to explain them:

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

 

 

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 

Link to comment
Share on other sites



×
×
  • Create New...