mIRC Home    About    Download    Register    News    Help

Topic Options
#213647 - 04/07/09 05:06 PM $remtok prob
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
Hello,

I create this alias but when i used only one nick removes from the %AJM_nicks list why? i saw that did not make a loop :S any help?

Code:
alias ajm_check {
  if (!%AJM_nicks) { halt }
  ; %AJM_nicks westor,westor1,westor2,westor3,westor4,westor5,westor6,westor7,westor8
  var %i = 1
  while (%i <= $numtok(%AJM_nicks,44)) {
    var %ch = $gettok(%AJM_nicks,%i,44)
    if ((!%AJM_ [ $+ [ %ch ] $+ ] _message) && ($istok(%AJM_nicks,%ch,44))) { set %AJM_nicks $remtok(%AJM_nicks,%ch,44) | echo -s Successfully removed %ch nick }
    inc %i
  }
  inc %i
}
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#213650 - 04/07/09 05:42 PM Re: $remtok prob [Re: westor]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
1) The line where the variable %AJM_nicks is set has a ; in front of it, which, in mIRC scripting terms means that the line is a remark, and is not to be processed.

2) The condition
Code:
($istok(%AJM_nicks,%ch,44)
is irrelevant, as you are creating the %ch variable from the %AJM_nicks variable, in the line immediately proceeding that line.

3)
Code:
$remtok(%AJM_nicks,%ch,44)
is missing the parameter to tell mIRC which occurrence of %ch is to be removed from %AJM_nicks. See /help $remtok

4) By removing %ch from %AJM_nicks, then increasing the %i variable, going from the original variable, the nicks removed would be the 1st, 3rd, 6th, 10th, etc.

5) You have an additional inc %i in your code, which would execute after the loop has finished.

Top
#213653 - 04/07/09 05:54 PM Re: $remtok prob [Re: RusselB]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
the ; i gave you to see what i have into my variables setted that line is not in the alias , any way can you help me with giving me an correct example ?
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#213655 - 04/07/09 06:21 PM Re: $remtok prob [Re: RusselB]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3463
Loc: France
$remtok(%AJM_nicks,%ch,44) is fine, by defaut the first "occurence" is removed
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#213656 - 04/07/09 06:26 PM Re: $remtok prob [Re: Wims]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
Originally Posted By: Wims
$remtok(%AJM_nicks,%ch,44) is fine, by defaut the first "occurence" is removed


what do you mean with this , give an example!
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#213657 - 04/07/09 07:24 PM Re: $remtok prob [Re: westor]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
If you remove a token, you mustn't increase the numer in your loop.
Code:
alias example {
  var %example = 1 2 3 4 5 6
  var %n = 1
  while ($gettok(%example,%n,32)) {
    if ($v1 isnum) { var %example = $deltok(%example,%n,32) } 
    inc %n
  } 
  echo -a tokens remaining: %example
}
Will remove all the tokens, because they are all numbers, right?
Nope. If you delete a token and increase the number, the script "skips" some tokens: Token number one is deleted, and the token "2" is now token number one. If you inc %n to 2, the script continues with token number two - which is: "3"!
If it shall check every token: use "else inc %n"
Alternatively:
- use a decreasing loop if your script may delete the Nth token
- don't change the variable during the loop. Instead (for example) add the tokens you want to keep to a separate variable; and use the new variable, or replace the original variable with the data of the new variable after your loop has finished.

Top
#213658 - 04/07/09 07:55 PM Re: $remtok prob [Re: westor]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
For example:
Code:
alias ajm_check {
  var %AJM_nicks = westor,westor1,westor2,westor3,westor4,westor5,westor6,westor7,westor8
  var %ch = $numtok(%AJM_nicks,44)
  while (%ch) {
    set %AJM_nicks $remtok(%AJM_nicks,$gettok(%AJM_nicks,%ch,44),44))
    echo -s %AJM_nicks removed.
    dec %ch
  }
}
The echo isn't needed but just to show you how all the tokens are removed one after another.

Top
#213659 - 04/07/09 07:56 PM Re: $remtok prob [Re: westor]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3463
Loc: France
Why wait for an exemple when you can just testing this by yourself with one second ?

Anyway, the help give this syntax :
$remtok(text,token,N,C)
N can be omitted, $remtok(text,token,1,C) is the same as $remtok(text,token,C) and this works for most token identifiers if not all
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top