mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
im attempting to delete all items NOT matching *.*

for example, items such as

nick -> user
this -> that

would be deleted, and items such as

nick.them -> user
this.something -> that

would NOT be deleted... Im using the code below...

Code:
alias del_users {
 var %x = 1
 while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {
   hdel nicks $hfind(nicks,/^?!((.+?)\.(.+?)))/,%x,r)
   inc %x
 }
}


The trouble is.. if there's 3 entries, it only deletes the first 2... if there's 6 it only deletes the first 5....

i have tried it with var %x = 0 and also tried it as < instead of <= in the while...

any ideas???

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The problem is that you're deleting an item and increasing %x.

Try this instead
Code:
alias del_users {
 var %x = 1
 while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {
   hdel nicks $hfind(nicks,/^?!((.+?)\.(.+?)))/,%x,r)
   dec %x
 }
 inc %x
}


Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
That just freezes mIRC...

* Break: command halted (line 278, core.aow)

line 278 = while (%x <= $hfind(nicks,/^?!((.+?)\.(.+?)))/,0,r)) {

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
When you delete the 1st matching item, what was the 2nd is now the 1st, so you just need to keep deleting the 1st match wink
Code:
alias del_users {
  while ($hfind(nicks,/^[^.]+$/,1,r)) { hdel nicks $v1 }
}

Joined: Oct 2006
Posts: 48
G
Ghozer Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2006
Posts: 48
ty deegee - i thought something similar, but using my longer regex wink

works perfect that wink n1


Link Copied to Clipboard