|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
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?
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
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
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 ($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) $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.
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
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 ?
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
$remtok(%AJM_nicks,%ch,44) is fine, by defaut the first "occurence" is removed
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
$remtok(%AJM_nicks,%ch,44) is fine, by defaut the first "occurence" is removed what do you mean with this , give an example!
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
If you remove a token, you mustn't increase the numer in your loop. 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.
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
For example: 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.
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
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
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
|