PRO ls,filter,FILES=files,DIRECTORY=dir,COUNT=count,NOPRINT=noprint ;+ ;ls lists the files in the current directory. ;ls,filter causes files containing the specified filter string ; to be selected. ; Example: ls,'*.tif' selects tiff files. ; Any selection string accepted by FINDFILE can be used. ; ;KEYWORDS ;FILES=files returns the list in the string array "files". ; ;DIRECTORY=dir causes files in directory "dir" to be listed. ; ;COUNT=count returns the number of files found. ; ;NOPRINT: /NOPRINT to suppress printing. (Default is to print.) ; ;February 2002: Added NOPRINT keyword. ;- ;Get the current directory cd,current=current ;If a new directory is given, then switch to it. IF N_Elements(dir) GT 0 THEN cd,dir ELSE dir=current IF N_Elements(filter) GT 0 THEN files=FindFile(filter,COUNT=count) ELSE $ files=FindFile(COUNT=count) cd,current ;Switch back to original directory. k=Sort(StrUpCase(files)) files=files[k] files=Reform(files,1,N_Elements(files)) ;Print the file list unless NOPRINT is set IF NOT KEYWORD_SET(noprint) THEN BEGIN Print,'Files from directory '+ dir Print,files ENDIF END