mIRC Homepage
Posted By: kwell Random order - 12/06/11 01:12 PM
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!
Posted By: Wims Re: Random order - 12/06/11 02:02 PM
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)
  }
}

Posted By: kwell Re: Random order - 12/06/11 02:20 PM
One question, "$r" works like "$rand"?
Works great!!! thanks Wims!
Posted By: Wims Re: Random order - 12/06/11 02:33 PM
Yes, $r is $rand, and you are welcome smile
Posted By: Tomao Re: Random order - 12/06/11 06:14 PM
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)))
}
Posted By: Tomao Re: Random order - 12/06/11 06:19 PM
Never mind Wims. I misread the question. It only returns one result. blush
© mIRC Discussion Forums