function sft_files, st_date, en_date, count=count
;+
; NAME:
;	sft_files
; PURPOSE:
;	Return a list of sft (SXT terminator) file names
; CALLING SEQUENCE:
;	fn = sft_files() 		; Lastest file
;	fn = sft_files('1-jan')		; File for 1-jan of this year
;	fn = sft_files('30-oct-91', '2-nov-91')
; INPUT:
;	st_date	- The UT date to search for.  If no date is entered,
;		  the current date is used.  The year is not
;		  required, but if entered should be of the
;		  form 1-Oct-91 style.  The date should be
;		  entered in string style with date first.
; OPTIONAL INPUT:
;	en_date	- The ending date to list data for.  If no date is passed,
;		  it only searches for "st_date"
; OPTIONAL KEYWORD INPUT:
;	None.
; OUTPUT:
;	Vector string of file names
; PROCEDURE:
; 	sft_files searches the sft files on $DIR_GEN_SFT directory.
;	The latest version of the file is returned.
; HISTORY:
;	12-Oct-94, J. R. Lemen, Written.
;-

DIR = '$DIR_SXT_SFT'			; Location of the files
prefix = concat_dir(DIR,'sft')		; This should work on VMS also

if n_elements(st_date) eq 0 then begin	; Is the start time defined?
    day_arr1 = strmid(!stime, 0, 6)	; Use the current time if not defined
endif else day_arr1 = st_date

if n_elements(en_date) eq 0 then begin	; If no stop time, stop = 26 hrs + start time
    day_arr2 = addtime(day_arr1,delta=26.*60.*60,/sec)
endif else day_arr2 = en_date

week_ids = tim2weekid(day_arr1,day_arr2)	; Get the file IDs
file_sea = prefix + week_ids + '*.*'		; This should work with VMS
nfile_sea = n_elements(file_sea)		; Number of weeks to search for
files = strarr(nfile_sea)
nfile = lonarr(nfile_sea)

for i=0,nfile_sea-1 do begin
  buff = findfile(file_sea(i),count=count)		; Search for the files
  nfile(i) = count
  if count then files(i) = buff(count-1)	; Take most recent file  
endfor

ii = where(nfile,count)
if count eq 0 then begin
  message,'No sft files found',/info
  files = ''
endif else files = files(ii)
return,files
end
