pro dump_ipreg, infil, ss, last=last
;
;
;
;
list_tfi, infil, info
;
if (n_elements(ss) eq 0) then ss = where((info.dpc eq 'bfffff65'x) or (info.dpc eq '20010000'x), nss)
if (keyword_set(last)) and (nss ne 0) then ss = ss(nss-1)	;get last one
if (ss(0) eq -1) then nss = 0 else nss = n_elements(ss)

for idset=0,nss-1 do begin
    read_mdi, infil, ss(idset), img, head
    dattim = gt_day(sxpar(head, 'DATE-OBS'),/str) + '  ' +  sxpar(head, 'TIME-OBS') 
    fid = ex2fid( anytim2ex(dattim) )
    outfil = concat_dir(getenv('MDI_TEMP_DIR'), 'dump_ipreg.' + fid)
    ;
    print, 'Saving Results to: ', outfil
    openw, lun, outfil, /get_lun
    printf, lun, 'DUMP_IPREG  Program Run: ' + !stime
    printf, lun, 'Input File: ' + infil + '    and data product #: ' + strtrim(ss(idset), 2)
    printf, lun, 'Dump of IP Reg Done: ' + dattim
    printf, lun, ' '
    ;
    ninlin = 20
    for i=0,8191,ninlin do begin
	ien = (i+ninlin)<8191
	str = string(i, img(i:ien) and 'ffff'x, format='(1x, i4, 3x, 99(1x, z4.4))')
	print, str
	printf, lun, str
    end
    free_lun, lun
    print, 'Results Saved to: ', outfil
end
;
end