This supports .ini files and alias files, in addition to remote scripts. Note that the alias cannot detect remote scripts from alias files, so it will still detect "/op /mode # +o $1" as an alias if it was placed at the beginning of the line in a remote script, which mIRC wouldn't recognize. You could add another switch to the identifier to denote whether the file was a remote/aliases file, or you could just handle this case in another way.

Code:
alias aliasname {
  var %file = $1, %index = $2, %w = @__aliasname
  var %match = /^ $+ $iif(*.ini iswm %file,(?:n\d+=),) $+ $&
    (?:alias\s+(?:-l\s+)?)?\/?([^\{ \[#;]+).*$/
  if (!$exists(%file)) return $null
  if ($window(%w)) clear %w
  window -h %w
  filter -gfw %file %w %match
  var %value = $line(%w,%index)
  if (%index != 0) %value = $regsubex(%value,%match,\1)
  window -c %w
  return %value
}


I should point out that this script relies on proper indenting from the script editor. If you edit your scripts in another file, make sure to hit Ctrl+H in the script editor to properly indent the file.

Note: From the sound of it, it seems like your goal here is to loop over the aliases. If you plan on looping over all $aliasname(file,N) (where N=1..total), it would be much more efficient to create your own custom version of this that uses /filter -k instead of filtering to a separate window. It would look like this:

Code:
; Usage: /aliasname_loop <filename> <command>
alias aliasname_loop {
  set -u0 %aliasname.file $1
  set -u0 %aliasname.callback $2-
  set -u0 %aliasname.num 0
  set -u0 %aliasname.match /^ $+ $iif(*.ini iswm %aliasname.file,(?:n\d+=),) $+ $&
    (?:alias\s+(?:-l\s+)?)?\/?([^\{ \[#;]+).*$/
  if (!$exists(%aliasname.file)) return $null
  filter -fk %aliasname.file aliasname_filter *
  unset %aliasname.*
}
alias aliasname_filter {
  if ($regex($1-,%aliasname.match)) {
    inc %aliasname.num
    %aliasname.callback %aliasname.num $regml(1)
  }
}


Calling "/aliasname_loop aliases.ini /echo -a" would /echo -a each resulting alias where $1 = the index and $2 = the alias name. You could make the command a custom alias that processes each result.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"