mIRC Homepage
Posted By: FroggieDaFrog /filter recursion - 16/09/10 05:39 AM
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
Posted By: jaytea Re: /filter recursion - 16/09/10 07:26 AM
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
Posted By: Wims Re: /filter recursion - 16/09/10 08:17 AM
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
Posted By: FroggieDaFrog Re: /filter recursion - 16/09/10 08:41 AM
Recursion can be, but I wasn't shooting for that. Just had a typo in the code and discovered this smile
Posted By: jaytea Re: /filter recursion - 16/09/10 08:43 AM
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!
Posted By: Khaled Re: /filter recursion - 16/09/10 05:48 PM
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.
© mIRC Discussion Forums