Code:
alias count.aliases {
  if (!$isfile($1)) return
  set -u %count.aliases 
  filter -fk $+(",$1,") _count.aliases alias *
  return $filtered - %count.aliases
}

alias -l _count.aliases {
  tokenize 32 $1
  var %alias = $iif($2 != -l,$2,$3)
  if ($len(%alias %count.aliases) < 920) {
    set -u %count.aliases $addtok(%count.aliases,%alias,44)
  }
}


It will discard any variable names when the length of the total list starts exceeding 920 characters. You wouldn't be able to return them if they exceed the string too long limit, there are of course ways to store those alias names in a binvar or something, but that will probably confuse you. It also ignores doubles in the aliases names because of $addtok.

EDIT: Here's an example with binvars:

Code:
alias countaliases {
  if (!$isfile($1)) return No such file: $1
  bset -c &aliases 1 32
  filter -fk $+(",$1,") _countaliases alias *
  hadd -bm aliases $md5($1) &aliases
  return $filtered - $bvar(&aliases,1,920).text
}

alias _countaliases {
  tokenize 32 $1
  bset -t &aliases $calc(1+$bvar(&aliases,0)) $$iif($2 != -l,$2,$3) $+ ,
}


Example:

//echo -a $countaliases($mircdirown files\test.mrc)

Now hash table "aliases" will contain an item named $md5($mircdirown files\test.mrc) and to access the data without having to worry about the string too long limit, you can put it in a binvar like this:

//!.echo -q $hget(aliases,$md5($mircdirown files\test.mrc),&data) | echo -a Total bytes: $bvar(&data,0)

Which in term let's you retrieve chunks from this bvar with $bvar.

The reason I use $md5 is to get rid of spaces in your filepath, as you know hash table items must not contain spaces.