mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 6
T
tweaqer Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Aug 2004
Posts: 6
Hey all, i have a textfile with loads of lines. I want the user in the channel to search within this file and get the results (max 5) returned.
The problem is that i only want the the first, the third and the fourth item to show from the line. I came up with this:

Code:
ON *:TEXT:!search*:#mychannel: {
  var %string = $2-
  msg $chan Searching for %string
  window -h @@
  filter -fw C:\quotes.txt @@ $+(*,%string,*)
  msg $chan There were $filtered quotes found showing 5
  if $filtered { savebuf 5 @@ quotes.tmp | write quotes.tmp End of results | play $nick quotes.tmp 1000 | .remove quotes.tmp 
  window -c @@ }
}


This only gives back the entire line it found a result on instead of giving the the first, the third and the fourth part of the line.
Would you have a solution for my problem?

Thanks, you guys are the best! grin

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
ON *:TEXT:!search*:#mychannel: {
  var %string = $2-
  msg $chan Searching for %string
  window -h @@
  filter -fk C:\quotes.txt line.chopper.upper $+(*,%string,*)
  msg $chan There were $filtered quotes found showing 5
  if $line(@@,0) { savebuf 5 @@ quotes.tmp | write quotes.tmp End of results | play $nick quotes.tmp 1000 | .remove quotes.tmp 
  window -c @@ }
}
;
;** below alias sends only whats needed to the @@ window **
;
alias -l line.chopper.upper {
  tokenize 32 $1
  if (%string isin $1 $3 $4) aline @@ $1 $3 $4
}
;
;****** If you dont need to ensure the %string is in $1 $3 $4 then just use the alias below instead of the one above. ******
;
alias -l line.chopper.upper {
  tokenize 32 $1
  aline @@ $1 $3 $4
}


I assumed the 1st,3rd & 4th parts of the line were the 1st 3rd & 4th word, since you didnt tell me any differently.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
An alternative to what Dave posted would be this:

Make a custom alias like:

alias -l playtonick notice $1-2 $4-5

and use the -a flag that comes with /play like:

play -a playtonick $nick quotes.tmp

Btw the default delay is 1000 ms, so no need to specify it.


Gone.

Link Copied to Clipboard