pro rd_obs, sttim, entim, bcs0, sxtf0, sxtp0, w_h0, fid0, $
		bcs=bcs, sxtf=sxtf, sxtp=sxtp, w_h=w_h, $
		nobcs=nobcs, nosxtf=nosxtf, nosxtp=nosxtp, now_h=now_h, $
		infil=infil, status=status, quiet=quiet
;
;+
;Name:
;	rd_obs
;Purpose:
;	Routine to read the observing log into vectors
;CALLING SEQUENCE:
;	rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, fid
;	rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h
;	rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /sxtp, /sxtf
;	rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /nobcs
;INPUT:
;       sttim   - start time in any format
;       entim   - end time in any format
;OUTPUT:
;	bcs	- The BCS observing log structure
;	hxt	- The HXT observing log structure
;	sxtf	- The SXT FFI observing log structure
;	sxtp	- The SXT PFI observing log structure
;	w_h	- The WBS and HXT observing log structure
;	fid	- The File ID observing log structure
;OPTIONAL KEYWORD INPUT:
;	/bcs	- Indicates that the BCS entries should be read
;
;		  (The "positive" or "negative (/nobcs)" switches 
;		  can be used in conjunction with the parameter
;		  list in the calling sequence to determine which
;		  instrument logs to read)
;		  
;		  (if SXTP and W_H are not included in the call to RD_OBS, 
;		  then they will not be read)
;
;	/sxtf	- Indicates that the SXT full frame entries should be read
;	/sxtp	- Indicates that the SXT partial frame entries should be read
;	/w_h	- Indicates that the WBS/HXT entries should be read
;	/nobcs	- Don't read the BCS entries
;	/nosxtf	- Don't read the SXT full frame entries
;	/nosxtp	- Don't read the SXT parital frame entries
;	/now_h	- Don't read the WBS/HXT entries
;	infil	- It is posssible to pass in the file name directly
;		  instead of the starting/ending times.
;OPTIONAL KEYWORD OUTPUT:
;       status  - The read status
;                 Some data is available if (status le 0)
;                        0 = no error
;                        1 = cannot find the file
;                        2 = cannot find data in the time period
;                       99 = cannot recognize the data_type (prefix)
;                       -1 = found data, but had to go outside of the requested
;                            period (only true if /NEAREST is used).
;MORE SAMPLE CALLING SEQUENCES:
;	The negative or positive keyword switches are provided to eliminate
;	reading unneccessary logs and to reduce typing, e.g.,
;
;	To return only BCS observing log
;       	rd_obs, sttim, entim, bcs
;	To return all observing logs
;		rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h
;	To return only the WBS/HXT observing log
;		rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /nobcs, /nosxtf, /nosxtp
;	or, use the positive keyword switch
;		rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /w-h
;	To return only the SXT-FFI observing log
;		rd_obs, sttim, entim, bcs, sxtf, /nobcs
; 	or 	rd_obs, sttim, entim, bcs, sxtf, /sxtf
;	To return the WBS/HXT and BCS logs
;		rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /nosxtf, /nosxtp
;	or	rd_obs, sttim, entim, bcs, sxtf, sxtp, w_h, /bcs, /w_h
;COMMENTS:
;	The observing log data files must be located in the $DIR_GEN_OBS
;	directory.
;
;	The output arrays are positional instead of keyword to allow
;	for less typing.  The order of the outputs is alphabetical in
;	order to be more easily memorized (except the fid file is at
;	the end)
;HISTORY:
;	Written Summer '91 by M.Morrison
;	 9-Jul-92 (MDM) - Changed the calling sequence to match all of the
;			  other reading routines (RD_PNT, RD_FEM, ...)
;	26-Oct-92 (MDM) - Moved the FREE_LUN call to inside the week loop
;			- Changed the names of the buffer variables.
;			  Used to be BCS,SXTP, ... now is BCS00,SXTP00, ...
;			  since there is keyword input /BCS - dont want
;			  to clobber that input.
;			- Checked to see how many parameters there were on
;			  the calling sequence and read/save the data
;			  accordingly (if don't have SXTP in calling seqence
;			  positionally, then don't save them)
;	23-Nov-92 (MDM) - Adjusted logic so that if "bcs=0" keyword option 
;			  was used, it would be recognized (since KEYWORD_SET
;			  would not recognized it and saying "no")
;			- Added comments to the header
;	28-Jan-93 (MDM) - Modified to return only the entries between the
;			  requested times (before, it returned full orbits
;			  of data)
;	15-Apr-93 (MDM) - Changed {obs_bcs_rec} to {obs_bcs_obs_rec}
;			  *****************************************************
;	21-Apr-93 (MDM) - Changed to read the new observing log files which are
;			  a file per instrument.  Call RD_OLD_OBS if the new
;			  files are not available.
;	 9-Jun-93 (MDM) - Corrected small bug
;	 1-Oct-93 (MDM) - Added STATUS keyword
;	21-Feb-94 (MDM) - Modified header information
;	 8-Mar-94 (MDM) - Added /QUIET option
;-
;
gen_struct
obs_struct
;
qdebug = 1
if (keyword_set(quiet)) then qdebug=0
;
qfid = 1 		;always read FID
qsxtp = 0
qsxtf = 0
qbcs = 0
qw_h = 0
;
if (keyword_set(bcs))  then qbcs=1
if (keyword_set(sxtf)) then qsxtf=1
if (keyword_set(sxtp)) then qsxtp=1
if (keyword_set(w_h))  then qw_h=1
if ( (not qbcs) and (not qsxtf) and (not qsxtp) and (not qw_h)) then begin
    qsxtp = 1
    qsxtf = 1
    qbcs = 1
    qw_h = 1
end
if (n_elements(bcs) ne 0)  then if (bcs eq 0) then qbcs = 0	;a value was passed in and it was equal to zero
if (n_elements(sxtf) ne 0) then if (sxtf eq 0) then qsxtf = 0	;added 23-Nov-92
if (n_elements(sxtp) ne 0) then if (sxtp eq 0) then qsxtp = 0
if (n_elements(w_h) ne 0)  then if (w_h eq 0) then qw_h = 0
if (keyword_set(nobcs))  then qbcs=0
if (keyword_set(nosxtf)) then qsxtf=0
if (keyword_set(nosxtp)) then qsxtp=0
if (keyword_set(now_h))  then qw_h=0
;
if (n_params(0) le 5) then qw_h = 0	;no output parameter, then don't bother saving it
if (n_params(0) le 4) then qsxtp = 0	;no output parameter, then don't bother saving it
if (n_params(0) le 3) then qsxtf = 0	;no output parameter, then don't bother saving it
if (n_params(0) le 2) then qbcs = 0	;no output parameter, then don't bother saving it
;
ans_arr = ['No ', 'Yes']
if (qdebug) then print, 'BCS: ', ans_arr(qbcs), $
			'        SXTF: ', ans_arr(qsxtf), $
			'        SXTP: ', ans_arr(qsxtp), $
			'        W_H: ', ans_arr(qw_h)
;
status = 0
status0 = 0
;if (qsxtp) then rd_week_file, sttim, entim, 'OSP', sxtp0, fid0, status=status0	& status = min([status, status0])
if (qsxtp) then rd_week_file, sttim, entim, 'OSP', sxtp0, fid0, status=status0	& status = status or (status0 eq 1)
if (qsxtf) then rd_week_file, sttim, entim, 'OSF', sxtf0, fid0, status=status0	& status = status or (status0 eq 1)
if (qbcs)  then rd_week_file, sttim, entim, 'OBD', bcs0,  fid0, status=status0	& status = status or (status0 eq 1)
if (qw_h)  then rd_week_file, sttim, entim, 'OWH', w_h0,  fid0, status=status0	& status = status or (status0 eq 1)
;
if (status eq 1) then begin	;none of the above found files
	rd_old_obs, sttim, entim, bcs0, sxtf0, sxtp0, w_h0, fid0, $
		bcs=bcs, sxtf=sxtf, sxtp=sxtp, w_h=w_h, $
		nobcs=nobcs, nosxtf=nosxtf, nosxtp=nosxtp, now_h=now_h, $
		infil=infil
end
;
end
