I can't reproduce this problem with the script as you have given it...

Why would you want to count the number of [aliases] section headers?? There should only ever be one. A more useful alias would count the number of actual aliases...

Code:
alias countaliases {
  var %file $1
  var %lines $lines(%file)
  var %index 1 | var %ln | var %depth 0 | var %count 0
  while (%index <= %lines) {
    set %ln $read(%file, nt, %index)
    var %pos $pos(%ln, $chr(59))
    if (%pos) set %ln $left(%ln, ($calc(%pos - 1)))
    if (!%ln) { inc %index | continue }
    if (%depth == 0) {
      if ([aliases] isin %ln) noop
      else if ([remotes] isin %ln) noop
      else if (popup] isin %ln) noop
      else if ($chr(35) == $left(%ln, 1)) noop
      else if ($chr(123) !isin %ln) && ($chr(125) !isin %ln) inc %count
      else if (alias == $left(%ln, 5)) || (=alias isin %ln) inc %count
    }
    if ($chr(123) isin %ln) inc %depth $count(%ln, $chr(123))
    if ($chr(125) isin %ln) dec %depth $count(%ln, $chr(125))
    inc %index
  }
  if (%depth != 0) { echo -a countaliases: Missmatched curly brackets in %file }
  return %count
}


Edit: It's not "perfect"... Strange programming styles or putting vars, popups, or user ini sections in the same file that has remotes or alias, might mess with it, but with some tweaking, it should work nicely...

Last edited by NaquadaServ; 13/05/07 03:10 PM.

NaquadaBomb
www.mirc-dll.com