;+
pro rdsci, fn
; 
; Reads and displays one data block from 5k data files.
; The argument specifies the base file name, without the number and extension.
;
; 5k data files contain upto 50 records of 424 bytes each.
; The records contain a 42 byte header followed by a 382 byte data block.
;-

hdr = bytarr(32)
pkt = intarr(196)
num = 1
status = 0
recnum = 0

filename = '$MDI_SCI5K_DIR/'+ fn + string (num, format = '("_", i2.2, ".sci")')
openr, lun, filename, /get_lun, error = status

while (status eq 0) do begin
    recnum = 0
    while (not eof(lun)) do begin
        print, filename, recnum
        print, ' '
        readu, lun, hdr, pkt
        print, hdr, format = '(16z4)'
        print, ' '
        print, pkt(0:3) and 'ffff'x, format = '(4z5.4)'
        print, ' '
        print, pkt(4:*) and 'ffff'x, format = '(12z5.4)'
        print, ' '
        r = get_kbrd (1)
        recnum = recnum + 1
    endwhile
    close, lun
    num = num + 1
    filename = '$MDI_SCI5K_DIR/'+ fn + $
               string (num, format = '("_", i2.2, ".sci")')
    openr, lun, filename, error = status
endwhile

exit:
return
end

