mIRC Home    About    Download    Register    News    Help

Print Thread
Random order #232607 12/06/11 01:12 PM
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Question: this is a question?@yes@no@perhaps
Code:
alias question {
  echo -s $gettok(%questions,1,64)
  var %i = 2 
  while (%i <= $numtok(%questions,64)) {
    echo -s $gettok(%questions,%i,64)
    inc %i 
  }
}

/question show me
Question: this is a question?
yes
no
perhaps

As I do at random? eg:

/question
Question: this is a question?
perhaps
yes
no

/question
Question: this is a question?
no
perhaps
yes

thanks!

Re: Random order [Re: kwell] #232608 12/06/11 02:02 PM
Joined: Jul 2006
Posts: 3,931
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,931
Code:
alias question {
  echo -s $gettok(%questions,1,64)
  var %t %questions
  while ($numtok(%t,64) > 1) && ($r(2,$v1)) {
    echo -s $gettok(%t,$v1,64)
    %t = $deltok(%t,$v1,64)
  }
}


Last edited by Wims; 12/06/11 02:03 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Re: Random order [Re: Wims] #232609 12/06/11 02:20 PM
Joined: Sep 2007
Posts: 109
K
kwell Offline OP
Vogon poet
OP Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
One question, "$r" works like "$rand"?
Works great!!! thanks Wims!

Re: Random order [Re: kwell] #232610 12/06/11 02:33 PM
Joined: Jul 2006
Posts: 3,931
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,931
Yes, $r is $rand, and you are welcome smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Re: Random order [Re: Wims] #232612 12/06/11 06:14 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can do this with tokenize, making the code even shorter without a loop with $gettok() and $numtok():
Code:
alias question {
  tokenize 64 %questions
  echo -s $(,$+($,$r(1,$0)))
}

Re: Random order [Re: Tomao] #232614 12/06/11 06:19 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Never mind Wims. I misread the question. It only returns one result. blush