mIRC Home    About    Download    Register    News    Help

Print Thread
#226027 16/09/10 05:39 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Code:
alias filteralias {
  filter -wk @Win filteralias *
}


Had an error in my code, causing it to call the /filteralias from within the /filter command and mIRC crashed. Maybe there should be a check for this?

Using version 7.1

;Edited to display version

Last edited by FroggieDaFrog; 16/09/10 05:40 AM.

I am SReject
My Stuff
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
good catch, that should definitely return a stack related error. recursion with /filter can often be useful and, in case you weren't aware, the alias used with -k is called as an identifier so you can detect recursive calls using $isid


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
But the first call could be done as an $identifier already, I recall a feature like $calias which would return the name or informations about where the alias was called, would have been useful here


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Recursion can be, but I wasn't shooting for that. Just had a typo in the code and discovered this smile


I am SReject
My Stuff
Wims #226032 16/09/10 08:43 AM
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
indeed, you can of course pass extra information to the alias, here's an interesting example:

Code:
alias filteralias {
  if ($prop == recursive($1-)) {
    ; stuff
  }
  else {
    filter -fk a.txt filteralias($1).recursive
  }
}


it lends some insight into how /filter sets up the alias: by appending ($1-) to the given parameter, prefixing it with $ and evaluating the result in an environment where $1 is each line in turn. as such, you can pass extra parameters (if this $prop approach is a bit ugly) and whatever else to identify the calling routine.

that said, a $calias would be lovely!


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
This is due to /filter being a stack heavy command - it uses a large number of variables. I have fixed this for the next version. That said, even with the fix, your alias results in infinite recursion, so mIRC will freeze. The reason for this is that in all versions of mIRC, /filter is not halted if the alias returns an error. I can change /filter so that it halts on an error - if anyone thinks this might be an issue in terms of backwards compatibility, let me know.


Link Copied to Clipboard