mIRC Home    About    Download    Register    News    Help

Print Thread
#135679 15/11/05 12:25 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I think it would be convenient for filter to not only accept an alias as parameter, but to be able to put code directly in it, avoiding the need to specify an alias. This is particularly handy when helping people on IRC as you could give them one command instead of a command+alias.

Small examples to illustrate my point:

//filter -fk versions.txt echo -a $gettok($1,-1,32); * mirc v?.&
--> Would echo all the versions mentioned in versions.txt

//filter -fkn myfile.txt if ($1 // 2) echo -a $gettok($1,2-,32); *
--> Would echo all lines in myfile.txt that are even.

//filter -wlk $chan echo -a $1; *a*
--> Would echo all nicknames from the active channel which contain the char "a".

Note that the code is only evaluated when the read-in line from the buffer ($1) is returned. Thus specifying one slash (/) or two (//) makes no difference to the evalating of the code specified when using -k. Therefore it would not form a problem either to use pipes as long as it's within the code placeholder in filter.

As you can see, I put a ; to end the block of code. Without some sort of "stop" sign, mIRC wouldn't know where the matching expression starts. If you want to use the ; in the line of code, you'll have to specify $chr(59). Note that this is simply a suggestion, whatever way it's implemented (if at all), is Khaled's choice.

This suggestion may make the -k options too confusing, so a new flag could be preferred.

The following line of code:

//filter -fk myfile.txt inc %lines | inc %len $len($1); * | echo -a Results: lines: %lines - total length: %len

Would only echo the results after the filter has done its job, which is incrementing a global variable %lines, and incrementing another global variable %len with the length of each line. The code block is delimited again by the ; so that mIRC's parser knows where the matchtext begins.

Note that the above example is simply an illustration, I'm aware that getting the total amount of lines, and getting the total length of each line in the file can be retrieved with other methods, though that is irrelevant.

I'm not interested in possible "work-arounds" for the code examples posted, as they are merely examples, and they are already possible, when specifying an alias, and scripting an alias, however the feature suggestion is to be able to put code directly in the filter command when accompanied with the -k flag (or a new flag if necessary).

Note that my proposed syntax for this new feature is also merely an example, how it might be implemented in the future is up to Khaled.


Gone.
#135680 15/11/05 01:13 PM
Joined: Feb 2005
Posts: 681
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2005
Posts: 681
Yes I've wanted this too. To be able to not only call an
alias but to be able to call any command and be able to
supply parameters. Also I think it would be great to have
$filter and have it work just like $findfile except it searches
files, windows & dialogs instead of directories.

$filter(file | @window | dialog id,wildcard,N,@window | dialog id | command)


Link Copied to Clipboard