mIRC Home    About    Download    Register    News    Help

Print Thread
remove all lines from a custom window with dline ? #131991 06/10/05 01:56 PM
Joined: Jan 2004
Posts: 133
W
WarlockW Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
I need to beable to remove all lines from a custom window
the first word is always the same ..

/window -alkCs @test

/aline @test test 1 is a test
/aline @test test 2 is another test
/aline @test test 3 I am testing again
/aline @test test 4 Are you testing?
/aline @test test 5 THIS IS A TEST

I wana del all lines using the first word
%var-remove = test

Any help ?

Re: remove all lines from a custom window with dline ? #131992 06/10/05 02:07 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You know, you really need $fline to work for this to work really well...

But, here's a way without using that since you couldn't get it working...


Code:
alias removelines {
  if ($1 != $null) {
    var %c = 1
    var %i = $line(@test,0)
    while (%c <= %i) {
      if ($gettok($line(@test,%c),1,32) == $1) {
        dline @test %c
      }
      else inc %c
    }
  }
}

Use: /removelines test

Note that I put the inc in an else because if you remove a line, you don't want to increase the counter.


Invision Support
#Invision on irc.irchighway.net
Re: remove all lines from a custom window with dli #131993 06/10/05 02:10 PM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
you could also use /filter that would probably be faster.

Re: remove all lines from a custom window with dline ? #131994 06/10/05 02:34 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
/*

Usage: /filterx <window> <first words to match>

Example: /filterx @test test

Note that I use a regex pattern which will match standalone words only. Meaning if you specify "tes", it will not remove lines starting with "test" since the word "tes" is not the same as "test". If you do want that, then we can just use a simple wildcard instead of regex.

*/

Code:
alias filterx {
 [color:red]  [/color] 
  ; $1 = window
  ; $2- = first words
 [color:red]  [/color] 
  var %e = echo -ac info * /filterx: Error - 
  if (!$window($1)) %e No such window $1 
  elseif ($0 &lt; 2) %e Insufficient parameters 
  else filter -wwcg $1 $1 ^(?!(?i) $+ $2- $+ (?=\s|$))
}


For those wondering why I don't put: filter -wwcx $1 $1 $2- *, thats because if you would specify "test" it would not match on lines that only consist of the word "test". The space between test and the wildcard in the filter command forces there to be a space after "test".


Gone.
Re: remove all lines from a custom window with dline ? #131995 07/10/05 02:10 AM
Joined: Jan 2004
Posts: 133
W
WarlockW Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
Thanks for the replys guys .. sorry i didnt respond
quick .. i was at the hospital my mother fell 75 years old frown
and broke a arm ..

just got back .. i have tested both ways and as always ..
i cant get them to work frown Not sure why since ..
i dont even get a error .

seems like they should work ..

oH wHY oH wHY .. is it so mean to me lol

/window -alkCs @test

/aline @test-test [1]-test1 test 1 is a test
/aline @test-test [1]-test2 is another test
/aline @test-test [1]-test3 I am testing again
/aline @test-test [1]-test4 Are you testing?
/aline @test-test [1]-test5 THIS IS A TEST

/aline @test-test test-1 test 1 is a test
/aline @test-test test-2 is another test
/aline @test-test test-3 I am testing again
/aline @test-test test-4 Are you testing?
/aline @test-test test-5 THIS IS A TEST

I guessing cause of the format
This is How it looks ..

test-1
[1]-test

Help ?

----

Update ...

I used this also ..

/aline @test test 1 is a test
/aline @test test 2 is another test
/aline @test test 3 I am testing again
/aline @test test 4 Are you testing?
/aline @test test 5 THIS IS A TEST

tryed with the first word .. also frown No Luck ..
test

-------------------------------------------

OK ...

TADA ! I figured it out .. omg i forgot it had control codes

/aline @test BOLD test 1 is a test < blah

Anyway .. Sorry I am Such A Pain lol

And Yes it works fine ..

THANKS ! Great Job smile

Now .. How Do I Strip The Code first lol

cause all the lines have BOLD test 2 test this < ect
and it dels everything lol

Thanks smile :P

Last edited by WarlockW; 07/10/05 03:17 AM.
Re: remove all lines from a custom window with dline ? #131996 07/10/05 06:01 AM
Joined: Jul 2003
Posts: 655
Om3n Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
This is probably why your $fline has trouble too. I did mention you had to be aware of and take into concideration control codes.


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Re: remove all lines from a custom window with dline ? #131997 07/10/05 01:24 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Use $strip to remove codes. So, in my example, you'd use:

if ($strip($gettok($line(@test,%c),1,32)) == $1)

Basically, you put $strip( ) around anything that has control codes. Or, you could just do something like:

if ($gettok($line(@test,%c),1,32) ==  $+ $1)

(i.e. Putting bold on the input itself if you know it will always have bold).

Or, just use /removelines Test


And, as mentioned, this is probably your issue with $fline. Try that out again and see if it works if you use $strip there.


Invision Support
#Invision on irc.irchighway.net
Re: remove all lines from a custom window with dline ? #131998 07/10/05 01:42 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
And in my example simply make this small change (in red):

filter -wwcgb $1 $1 ^(?!(?i) $+ $2- $+ (?=\s|$))

In other words, add a "b" to the flags, which will strip burc codes when trying to match.


Gone.
Re: remove all lines from a custom window with dline ? #131999 07/10/05 03:29 PM
Joined: Jan 2004
Posts: 133
W
WarlockW Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Jan 2004
Posts: 133
Thanks Guys ..

With all the help smile

works great now ..