PRO eis_report_study_db

s = fix_zdbase(/EIS)
;replace call to astrolib
defsysv,'!DEBUG', 0
defsysv,'!TEXTUNIT', 0
defsysv,'!PRIV', 2
defsysv,'!TEXTOUT', EXIST = EXIST

status = eis_open_db(/STUDY)
items  = db_info('entries')
print  , STRJOIN(['number of items = ',STRCOMPRESS(items[0])],/SINGLE)
OPENW  , lun , '$HOME/eis_report_db.txt' , /GET_LUN; , /APPEND
PRINTF , lun , 'ST_ID   ST_acronym            ST_duration'           +  $
               '             ST_volume             '                 +  $
               '       ST_DR (kBits/s)'

FOR i = 1, items[0]    DO BEGIN

    index   = STRCOMPRESS(i,/REMOVE_ALL)
    percent = STRCOMPRESS( (i/FLOAT(items[0]))*100. ,/REMOVE_ALL)
    print,STRJOIN(['Item: ',index,'  ',percent,'%  done.'],/SINGLE)
    st = db_read_study_entry(i)

    idValue = STRING(format='(I06)',st.id)

    format  = '(A-8,A-22,I-12,A-12,I-12,F-12.2,F12.4)'
    st_line = STRING(format=format,idValue,st.acronym,st.duration,      $
                      sec2dhms(st.duration/1000.),st.volume,            $
                      st.volume/1024.,                                  $
                      (st.volume/1024.)/(st.duration/1000.))
    PRINTF , lun , st_line

;stop

;
;
;
;    FOR j = 0, st_array[i].nRasters - 1 DO BEGIN
;
;        sra = db_read_studyraster_entry(i , j)
;        st_array[i].studyRasters[j] = sra
;
;    ENDFOR



ENDFOR

CLOSE , lun

;stop

END
