|
Joined: Oct 2006
Posts: 166
Vogon poet
|
OP
Vogon poet
Joined: Oct 2006
Posts: 166 |
A switch for /filter to stop filtering whenever matching matchtext
Kind Regards, blink
|
|
|
|
Joined: Apr 2005
Posts: 7
Nutrimatic drinks dispenser
|
Nutrimatic drinks dispenser
Joined: Apr 2005
Posts: 7 |
That would be $read() or $fline()
Last edited by Msmo; 10/11/06 02:20 AM.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
lol I was going to say that but i sumed he must have ment something more complexe as that seemed obvious.
|
|
|
|
Joined: Oct 2006
Posts: 166
Vogon poet
|
OP
Vogon poet
Joined: Oct 2006
Posts: 166 |
It would be better if it was a built-in feature. $fline if %line = %a break $read if %a = $readn break I always use /filter and I don't want to interupt it using loops.
Kind Regards, blink
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
I dont really see what your saying here honstly
however now you mention it, I seem to remember something about a change to allow mirc to abourt a filter operation that was being sent to an alias using -k, either it was int he watsnew file or mybe it was only a feature sggeston someone brought up? cant remember.
I think it was something like, wanting to be able to filter results but abort after collecting so many, which would be a lot faster than using $read or $fline. Fiberoptics name rings abell in connection to this, but don quot me on that either.
anyone able to lend a mention of this?
|
|
|
|
Joined: Oct 2006
Posts: 166
Vogon poet
|
OP
Vogon poet
Joined: Oct 2006
Posts: 166 |
-k won't be that good because I don't want to start an alias neither. only one /filter to do so.
Kind Regards, blink
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
/write -c outfile.txt $read(infile.txt,tw,*wild*string*,1)
-genius_at_work
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
I think you are missing something in the nature of /filter. Its designed to pull ALL matching lines from the source. If you want to just find the first match then use $read or $fline as you have had suggested to you.
|
|
|
|
Joined: Oct 2003
Posts: 313
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 313 |
Perhaps he wants /grep ? :> While we're at it, how about /find and /sed and /awk, oh, and /perl ;P Then we would be most of the way towards mIRCOS
Sais
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
Limiting /filter output can be brilliant when your sorting a file.
Much like SQL LIMIT sorting is done before LIMIT so therefor if you can limit /filter to get the 10 highest scoring nicknames you wont have to overhead of outputting the other 30.000, per example , to the output buffer.
$maybe
|
|
|
|
Joined: Oct 2006
Posts: 166
Vogon poet
|
OP
Vogon poet
Joined: Oct 2006
Posts: 166 |
As I mentioned that could be done with -k switch. but if there is a way to call one filter with all those options
Hey Martin long time no see!
Kind Regards, blink
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
since the condition that is ment to invoke the stopping of the filter could be anything, i doubt you well ever see if applyable to the /filter command itself.
You might want to stop after 10 mathes, or after 10 times where the 3rd parameter on the matched line is "Blob", or where the 9th parameter has been the same for the last 5 matches.
I doubt you could get all of them onto a command line.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Limiting /filter output can be brilliant when your sorting a file.
Much like SQL LIMIT sorting is done before LIMIT so therefor if you can limit /filter to get the 10 highest scoring nicknames you wont have to overhead of outputting the other 30.000, per example , to the output buffer. Well so can filter be stopped? it wasnt /halt in the -k alias becuase that did nothing when i tested it. I havent needed to do this for some time, but i still keep thinking i saw something about Khaled saying he had updated something so a repeditively called alias could stop the calling command (this might have been to do with findfile honestly im not sure). Currently if i have needed to i have used this approch alias example { .enable #example.filter.alias.group | filter -fk temp.txt example.filter.alias * }
;
#example.filter.alias.group off
;
alias -l example.filter.alias {
if (..no_longer_filtering..) { .disable #example.filter.alias.group | return }
;
..take_what_ever_action..
;
}
;
#example.filter.alias.group end
;
alias -l example.filter.alias { } Which while it cuts down the time taken as after not needing to filter its a simple empty alias, this method still incurs the over head in the initail command of looping the rest of the way through the source, which if its a say 2,000,000 line file can still take some time.
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
This could be a useful feature in some situations.
How about:
/filter -h#
-> Automatically stops filtering after the #th match. -> Example: /filter -ffh3 infile.txt outfile.txt *
and also:
/filter -h or /stopfilter
-> Manually stop the calling /filter command. (Must be used in the -k alias) -> Example: /filter -ffk infile.txt /outalias * --> alias outalias { if (d isin $1-) filter -h
-genius_at_work
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
I have never attempted to halt it, i personally would use something like:
alias example {
if ($hget(filter,0).item) hfree filter
hadd -m filter limit $1
filter -fk temp.txt example.filter.alias *
}
alias -l example.filter.alias {
hinc -m filter climit
if ($hget(filter,limit) <= $hget(filter,climit)) return
/*
..take_what_ever_action..
*/
}
If you can specify this directly to the /limit command you don't have the overhead of calling an alias repeatingly nor the overhead of writing more to the output buffer then is needed, saving quite some time. What i was trying to say is that sorting should have higher precedence then limiting. So that it wont sort the N limited matches but returns the N limited lines from the sorted input buffer.
$maybe
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
Sup blink
$maybe
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Fiberoptics name rings abell in connection to this, but don quot me on that either.
anyone able to lend a mention of this? It was here
Gone.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Well so can filter be stopped? it wasnt /halt in the -k alias becuase that did nothing when i tested it. I havent needed to do this for some time, but i still keep thinking i saw something about Khaled saying he had updated something so a repeditively called alias could stop the calling command (this might have been to do with findfile honestly im not sure). Yes, that was for $findfile(). However, /filter -k doesn't work like that; it goes through the entire infile, caches the results and then loops over those, calling the -k alias. Changing this in /filter would probably require major changes and create other problems. So what the OP wants (/filter not going through all lines in infile) is rather unlikely imo. That said, a nice (and quite feasible) alternative would be /halt stopping the -k alias from going through all lines in the cache, which in many cases is the bottleneck (even if the alias simply /returns, /filter is much faster without -k). Edit: Ok, seems the OP didn't want a /stopfilter, I must've mixed feature suggestions :tongue: I do remember it being mentioned recently but a quick search didn't find anything...
Last edited by qwerty; 14/11/06 03:35 PM.
|
|
|
|
Joined: Oct 2006
Posts: 166
Vogon poet
|
OP
Vogon poet
Joined: Oct 2006
Posts: 166 |
I think a custom alias /stopfilter would be great.
Kind Regards, blink
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Edit: Ok, seems the OP didn't want a /stopfilter, I must've mixed feature suggestions :tongue: I do remember it being mentioned recently but a quick search didn't find anything... LOL I thought thats exactly what he asked for. Oh well maybe he needs to explain a little more clearly (well at least for me)
|
|
|
|
|