mIRC Home    About    Download    Register    News    Help

Print Thread
#145076 18/03/06 06:40 AM
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
The /filter command supports using an alias as its target output, using the -k switch. Example:
  • /filter -wk @window /myalias *
This would dump everything from @window to /myalias, and each line would be interpreted as $1- within /myalias.

But what if you need to pass more than just the window output to your alias? Perhaps some instructions for the alias to handle the output in a special way? Well, you can't pass any parameters or switches to /myalias within the /filter command... Eg, /filter -wk @window /myalias [color:red]something *[/color], will not work. Solution?
  • /filter -wk @window $!myalias(something,$1-) *
Note the "!" in $!myalias() as this is important. Now when /myalias is called, $1 == something, and $2- == /filter output.

Here's a practical example, and the motive for discovery. I wanted to transfer output from one custom window to another, adding timestamps to the output. /filter doesn't support adding of timestamps, so I had to improvise.
  • ALIAS filter_ts { echo -t [color:purple]$1 $$2- }

    ALIAS copy_window { filter -wk @window1 $!filter_ts(@window2,$1-) * }[/color]
So when I call /copy_window, it will tell /filter to sent the contents of @window1 to /filter_ts, but with the $1 parameter of the target @window2.

You can also use built-in $identifiers instead of custom aliases, but you cannot use built-in /commands. Khaled disabled the ability for /commands to be used as $identifiers (after all the $quit(hahahah) abuse).

I hope you find this useful. Thanks to argv[0] for inspiration and support. smile


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#145077 18/03/06 07:48 AM
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
ya ive seen this somewhere before, quite a neat method, and well explained smile


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
#145078 18/03/06 09:06 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Great :-) works well, ill use that myself from now on when doing them and needing to pass extra parameters.

For some reason i had tried it before (using the ! to delay it) but for what ever reason i wasnt getting the $1- translating correctly, so had previously come to the conclusion that it didnt work frown

Maybe i just goofed and used a space infront of it?!?!, glad to know it works, I never did like having to use /SET's just to pass the extra values.


Link Copied to Clipboard