NAME:
  nextfile
 PURPOSE:
  Return the next (sorted) filename, from a search path, based upon a pattern.
 DESCRIPTION:
 CATEGORY:
  Miscellaneous
 CALLING SEQUENCE:
  result = nextfile(fname [,PATH=path,PATTERN=pattern,/PREVIOUS])
 INPUTS:
  fname : Current name to use as the reference. Scalar string.
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  PATH     : Search path. Default is the null string, which implies the
             current working directory.
  PATTERN  : The search pattern. Default is '*.*'
  PREVIOUS : If set, search in reverse instead of forward.
 OUTPUTS:
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Doug Loucks, Lowell Observatory, 2005/10/25