mIRC Home    About    Download    Register    News    Help

Print Thread
#89804 09/07/04 11:27 AM
Joined: Jan 2004
Posts: 24
W
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jan 2004
Posts: 24
Hi, I am trying to make an alias that shuffles the text, $shuffle(text)
It doesn't work though, I'll appriciate if someone helps me with that.
This is what I wrote:
alias shuffle {
var %l = $len($1-), %i = 0, %x, %t, %y
while (%i < %l) {
inc %i
var %t = $addtok(%t,$gettok($1-,%i,32),32)
}
var %x = 0
while (%x < %l) {
inc %x
var %y = $addtok(%y,$gettok(%t,$rand(%x,%l),32),32)
}
return %y
}


#89805 09/07/04 12:19 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
I hope you want to shuffle entire words, not shuffle all letters. Note that multiple consecutive spaces will be merged to one.

Code:
[color:blue]alias shuffle {
  var %i = 1, %len = $numtok($1-,32), %text = $1-, %shuffle, %r
  while (%i &lt;= %len) {
    var %shuffle = $instok(%shuffle,[color:black]$gettok(%text,1,32)[/color],[color:red]$rand(1,%i)[/color],32)
    var %text = $deltok(%text,1,32)
    inc %i
  }
  return %shuffle
}[/color]

#89806 09/07/04 04:00 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
If you are trying to shuffle word, this snipplet may prove to be helpful.


-KingTomato

Link Copied to Clipboard