pro hessiinfo,fname,silent=silent,strinfo=strinfo
if n_params(0) ne 1 then begin
print,' Usage: hessiinfo,fname,[/silent],[strinfo=strinfo]
print,'  fname -HESSI FITS file name'
print,'  strinfo - ounput FITS information string array'
print,'  /silent - no messages'
return
end

if (findfile(fname))(0) eq '' then begin
 strinfo=fname+' does not exist'
 goto,pend
end

if !version.os eq 'Win32' then ns='\' else ns='/'
j=rstrpos(fname,ns)
xname=strmid(fname,j+1,255)

ns=0
strinfo=strarr(5000)
xx=mrdfits(fname,ns,hdr,status=j,/sil)
if j lt 0 then begin
 strinfo=xname+' is not a FITS file'
 goto,pend
end
nn=fxpar(hdr,'ORIGIN')
if strtrim(string(nn(0)),2) ne 'HESSI' then begin
 strinfo=xname+' is not a HESSI FITS file'
 goto,pend
end
ext=fxpar(hdr,'EXTEND',count=j)
nn=fxpar(hdr,'NAXIS')

if (nn(0) ne 0) then begin
 strinfo(0)=xname+' is a HESSI FITS file'
 ext=fxpar(hdr,'NAXIS*')
 zz='('+string(nn)+'(",",I))'
 str='Image array ('+strmid(strcompress(string(ext,form=zz)),2,100)+')'
 strinfo(1)=str
 ns=2
 if n_elements(ext) ne 4 then begin
	strinfo(ns)='It is not a image array'
	goto,zend
	end
 if j eq 0 then goto,zend
end
;---BINTABLE---
xx=mrdfits(fname,1,hdr,status=j,/sil)
if j lt 0 then begin
	strinfo(ns)='file is corrupted'
	goto,zend
	endif else strinfo(ns)='----info----'
ns=ns+1
strinfo(ns)='Pixel size: '+string(fix(xx.pixel_size(0)))+string(fix(xx.pixel_size(1)))
ns=ns+1
strinfo(ns)='XY offset : '+string(fix(xx.xyoffset(0)))+string(fix(xx.xyoffset(1)))
ns=ns+1
strinfo(ns)=string(ext(2))+' energy bands:'
for i=0,ext(2)-1 do begin 
 ns=ns+1
 strinfo(ns)=string(fix(xx.ebands_arr(0,i)))+' - '+string(fix(xx.ebands_arr(1,i)))+'keV'
 end
ns=ns+1
strinfo(ns)=string(ext(3))+' time intervals:'
for i=0,ext(3)-1 do begin 
 ns=ns+1
 strinfo(ns)=string(i,form='(i4)')+': '+sec2date(xx.times_arr(0,i),dy=9)+$
 ' - '+sec2date(xx.times_arr(1,i),dy=9)
 end

zend: i=where(strinfo ne '')
 strinfo=strinfo(i)

pend: if not keyword_set(silent) then for i=0,n_elements(strinfo)-1 do print,strinfo(i)
end






