mIRC Home    About    Download    Register    News    Help

Print Thread
add/remove script #206784 25/11/08 03:05 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
What I want is a script that adds $6 to a list from #chan1

then if it appears in $4 in #chan2 to remove it from the list

then allow me to display what is left in the list using a command

and also allowing me to clear the list

I was thinking I could have an ontext event for #chan1 to add the info to a text file

then another ontext for #chan2 to search the file and remove the info if it exists

then for display use echo or /play

and for clearing the list use write -c to clear the file

is there a better way to do this?

Re: add/remove script [Re: firefox] #206785 25/11/08 03:13 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
If your list is not meant to last for multiple "sessions" of mIRC, you could use a @window instead of a file:
- in the adding on text event, create the window if it's not already created: if (!$window(@yourwindow)) ... and /aline new lines to that window.
- In the on text event for the other channel, scan for a matching line (line number) with $fline, and /dline that line in the @window.
- You now can hide/show the window whenever you like, with /window commands, and you can /clear your window as well.


Last edited by Horstl; 25/11/08 03:17 PM.
Re: add/remove script [Re: Horstl] #206786 25/11/08 03:29 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
I haven't used fline before would something like this work:

Code:
on *:TEXT:*:#chan2: {
  tokenize 32 $strip($1-)
  if ($nick == Bot2) && ($2 = INFO) {
  if $fline(@check,$4) { /dline $fline(@check,$4) }
}
}

Re: add/remove script [Re: firefox] #206787 25/11/08 03:41 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
If your list will contain single words only, yes. You're just missing the @window name in the dline command.
Try:

if $fline(@check,$4) { dline @check $v1 }

$ifmatch aka $v1 already holds the (first) matched line number.


Re: add/remove script [Re: Horstl] #206788 25/11/08 03:42 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
yes it will hold single words only

for future reference what if it doesn't?

Re: add/remove script [Re: firefox] #206789 25/11/08 03:50 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The matchtext definition in $fline works like the matchtext definitions of on text events: you can use *wildcards*, use & to represent single words etc.
In addition, you coud process multiple matched lines if you specify the N of $fline(@window,matchtext,N) and while-loop every N match. It's even possible to $fline for a regular expression.
In short, you can do virtually everything you could do with $read in a @window directly.

Re: add/remove script [Re: Horstl] #206794 25/11/08 06:36 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
thank you very much Horstl - it is working perfectly smile

Re: add/remove script [Re: firefox] #206840 26/11/08 01:12 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
one more query - if I want to manually remove a few lines containing some text - how do I do it?

I tried: /dline @check *flag*

but nothing happened do I need an alias with a $fline loop?

Re: add/remove script [Re: firefox] #206842 26/11/08 01:42 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Yepp, for example:
Code:
; /dentry <window> <wildtext string>
alias dentry { while ($fline($1,$$2-,1)) dline $1 $v1 }

Because it's deleting every matching line right off, in this case you don't have to inc the line number N (like a $fline(@window,text,N) loop)

Re: add/remove script [Re: Horstl] #206845 26/11/08 03:25 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
works great thanks again Horstl