function catrd_daily, date, long=long, raw=raw, yester=yester, $
              no_next=no_next, short=short, $
              records=records, filename=filename, tai=tai

; print, '%CATRD_DAILY-D-DATE, date = ' + date
;!quiet = 1

 if n_elements(yester) eq 0 then yester = 0 

 if not(keyword_set(raw)) then text = 1 else text = 0
 if keyword_set(short)    then short = 1 else short = 0

 ; The keyword /LONG:  0 mean sort cat records an remove duplicates and 
 ; display short format else raw order with all duplicates and print the
 ; values of every catalog element. 

 if keyword_set(long) then long = 1 else long = 0   

 ; Find the desired catalog

 dir_list = CAT_DIRECTORY( date,  cur_dir_cnt  = cur_dir_cnt,   $
                          use_last_rec = use_last_rec,  $
                  yester       = yester,    $
                  no_next      = no_next,   $
                          dir_cnt      = dir_cnt)

 if dir_cnt eq 0 then begin
    !quiet = 0
    return, 'No catalogs found in CAT_DIR:'     ; no catalogs   
 endif else if dir_list(0) eq '' then begin
    !quiet = 0
    return, ''
 endif

 ; Return the contents of the selected catalog as a "raw data" structure.

 entry = CAT_OPEN(   file  = dir_list(cur_dir_cnt), $       ; input
             long  = long,  $           ; input
             lun   = cat_unit,  $           ; output
             u_rec = u_rec,     $           ; output
             n_rec = n_rec,     $           ; output
             records = records)             ; output
        
 ; RECORDS is a array containing the record numbers of the catalog file
 ;         in the order indicated by the /LONG keyword
 ; U_REC   is the number of records to be used/considered
 ; N_REC   number of total record in the cat (excluding header)

 if text then cat_user = cat_to_text(entry(records-1),short=short) $ ; Remake into text
     else cat_user = entry(records-1) 

 !quiet = 0

 ; Return specifically requested keywords

 if n_elements(filename) gt 0 $
    then filename = (strupcase(entry.file_name))(records-1)
 if n_elements(tai) gt 0 then $
    tai = (utc2tai({mjd:entry.obs_time.mjd+49718, $
           time:entry.obs_time.sec*1000L}))(records-1)

return, cat_user
end