Code:
alias testar {
  var %z = $mircdirsystem\stats\
  if (!$exists(%z $+ $1 $+ .htm)) write -c $qt(%z $+ $1 $+ .htm)
  else write -c $qt(%z $+ $1 $+ $pn($1) $+ .htm)
}

alias pn {
  var %dir = $mircdirsystem\stats\, %ext = htm, %r
  window -h @found.files
  noop $findfile(%dir,$+(*,%ext),0,0,aline @found.files $nopath($1-))
  %r = $fline(@found.files,$+($1,*),0)
  window -c @found.files
  return %r
}

There may be other (even better) methods out there.