pro check_pro_names,lasco=lasco
;
;+
; NAME:
;	CHECK_PRO_NAMES
;
; PURPOSE:
;	This procedure checks for duplicate procedure names in $NRL_LIB
;
; CATEGORY:
;	LASCO UTIL
;
; CALLING SEQUENCE:
;	CHECK_PRO_NAMES
;
; INPUTS:
;	None
;	
; KEYWORD PARAMETERS:
;	LASCO:	Set this keyword to only print duplicates if they also occur
;		underneath the lasco directory.
;
; OUTPUTS:
;	This procedure writes the results to a file 'duplicate_pros.txt' in
;	the users home directory.
;
; PROCEDURE:
;	All files with pro in their name are found using the find commadn
;	Then only files ending in .pro and which are not in teh SCCS directory
;	are saved.  Duplicate file names are then located using the where 
;	function.
;
; MODIFICATION HISTORY:
; 	Written by:	RA Howard, NRL, 7 March 1997
;
;	@(#)check_pro_names.pro	1.1 09/26/97 LASCO IDL LIBRARY
;-
;
;  Create the file
;
CD,GETENV('NRL_LIB'),curr=olddir
SPAWN,'find . -print | grep pro',list
nlist = N_ELEMENTS(list)
names = STRARR(nlist)
fullnames = STRARR(nlist)
i = 0
s = ''
;
;  Process each record in the list
;  Check to make sure file name is valid
;  Split into file name and path
;
FOR jlist=0,nlist-1 DO BEGIN
   s = list(jlist)
;
;  Only accept names which end in .pro
;  Don't accept names with SCCS in them
;
   n = STRLEN(s)
   k = STRPOS (s,!delimiter+'SCCS'+!delimiter)
   IF ((k LT 0) AND ('.pro' EQ STRMID(s,n-4,4))) THEN BEGIN
      fullnames(i)=s
      n = RSTRPOS(s,!delimiter)
      names(i) = STRMID(s,n+1,strlen(s))
      i = i+1
   ENDIF
ENDFOR
CD,olddir
npro = i-1
duplicates = STRARR(500)
ndup = 0
PRINT,'Found ',npro,'  procedures'
IF (npro EQ 0)    THEN RETURN
;
;  Now find the duplicates
;
OPENW,luout,'duplicate_pros.txt',/get_lun
GET_UTC,dte
PRINTF,luout,UTC2STR(dte,/ecs)
PRINTF,luout,'Found ',npro,'  procedures'
PRINTF,luout,'Duplicate filenames'
PRINTF,luout
FOR i=0,npro DO BEGIN
    w = WHERE (names EQ names(i),nw)
    IF (nw gt 1)   THEN BEGIN
       ww = WHERE (names(i) EQ duplicates,nww)
       IF (nww LE 0)  THEN BEGIN
          duplicates(ndup)=names(i)
          ndup = ndup+1
          IF KEYWORD_SET(lasco)  THEN BEGIN
             plasco = STRPOS(fullnames(w),'lasco')
             lw = WHERE (plasco GT 0, nlw)
             IF (nlw GT 0)  THEN BEGIN
                FOR j=0,nw-1 DO PRINTf,luout,fullnames(w(j))
                PRINTF,luout
             ENDIF
          ENDIF ELSE BEGIN
                FOR j=0,nw-1 DO PRINTf,luout,fullnames(w(j))
                PRINTF,luout
          ENDELSE
       ENDIF
    ENDIF
ENDFOR
FREE_LUN,luout
RETURN
END
