pro rd_obs_entry, lun, data_section, recsize, block, struct, next_block
;
;+
;	Name:
;		rd_obs_entry
;	Purpose:
;		Read a single observing log entry out a log file
;
;	input:
;		lun   		unit number of openned observing log
;		data_section	initial pointer to "data-section" of obs
;				log.
;		recsize		File record size
;		block		index to "data-section", ranges from 1
;				to number of data-sets (ndset)
;	Output:
;		struct		output data for section "block".
;		next_block	block number for the next entry (cases where
;				there are mulitple block entries)
;
;HISTORY:
;	Written Fall '91 by M.Morrison
;       15-Apr-93 (MDM) - Changed {obs_bcs_rec} to {obs_bcs_obs_rec}
;	
;-
;	------------------------------------------------------------------
;
ibyt = (data_section + (block-1)*32L)	;TODO? not hardwire to 32?
off0 = ibyt				;save for later use
;
struct = {obs_wbshxt_rec}		;try WBS/HXT by default
rdwrt, 'R', lun, ibyt, 0, struct, 0	;do not update position, might have to re-read
;
entry_type = (struct.entry_type mod 32)
case entry_type of
     0: begin
		struct = {obs_FileID_rec}
		rdwrt, 'R', lun, ibyt, 0, struct, 0
		print, 'Read new File ID Entry ', string(struct.st$fileID)
	end
    15: begin
                struct = {obs_sxt_rec}
                rdwrt, 'R', lun, ibyt, 0, struct, 0
        end
    16: begin
		struct = {obs_sxt_rec}
		rdwrt, 'R', lun, ibyt, 0, struct, 0
	end
    17:			;do nothing - got it right already
    18: begin
		struct = {obs_bcs_obs_rec}
		rdwrt, 'R', lun, ibyt, 0, struct, 0
	end
    31: 		;do nothing - continuation marker
    else: begin
		print, 'RD_OBS_ENTRY - Unrecognized entry type'
		print, 'STOPPING ...'
		stop
	  end
endcase
;
point_lun, -1*lun, off
next_block = block + (off-off0)/32	;TODO - not hardwire to 32
			;^ should be 1 or 2 generally
;
end

