	PRO GetObsDat, fileNa, userTimes=userTim, key=key, which=which, $
			fid=fid, sxtp=sxtp, sxtf=sxtf, hxt=hxt, $
			wbs=wbs, bcs=bcs
;	---------------------------------------------------------------
;+							20-Aug-91
;	NAME:
;		GetObsDat
;	PURPOSE:
;		Get the observing log data-vectors for user requested 
;		times and search keys.
;	CALLING SEQUENCE:
;		GetObsDat, fileNa, [userTimes=userTim, key=key, which=which,
;		    	fid=fid, sxtp=sxtp, sxtf=sxtf, oth3=oth3]
;	INPUT:
;		fileNa		Observing log file name.
;				The input can be a vector of names.
;		userTim		list of user input times. For example,
;				start and end times (in order). format:
;				userTim = {struct, time:long, day:fix}
;		key		string containing a keyword specifing
;				search name and value: key = {structure,
;				name:string, value: string}
;		which       	A filter for extracting data: a string
;				vector containing the entries to
;				extract: (e.g. sxtp, sxtf, oth3).	
;	Output:
;		fid		data-vector of fileID logical records.
;		sxtp		data-vector of sxt logical records for 
;				partial frame images i.e. PFI.
;		sxtf		data-vector of sxt logical records for 
;				full frame images i.e. FFI.
;		bcs		data-vector of BCS instrument 
;		hxt		data-vector of HXT instrument 
;		wbs		data-vector of WBS instrument
;	HISTORY:
;		written 1-Apr-91 by GAL
;		modified 9-Apr-91 for two types of sxt logical records 
;		 	and a new data format.  Other changes include 
;			new interface to observing log access
;			rountines.
;		modified 7-May-91, name has been changed from GetObsda.
;			For each call it returns a map, fid, sxtp, sxtf,
;			oth3....  Inaddition, if usertim is 0 but a key
;			specified the whole file will be searched. If both
;			can be specified: example, time,NaBan.
;		modified 20-May-91, major upgrade for keyword searches
;			into the database.  
;		modified 26-July-91, to update documentation and formal
;			parameters.
;		modified 20-Aug-91, for hxt and wbs as seperate records.
;		modified 16-Oct-91 (MDM) to allow a vector of input 
;			filenames.  Also initialized the output vectors
;			so that previous searches are not appended.
;-
;	---------------------------------------------------------------
;	ON_ERROR, 2	;force a return to caller if error occurs
;
fid  = byte(0)
sxtf = byte(0)
sxtp = byte(0)
bcs  = byte(0)
wbs  = byte(0)
hxt  = byte(0)
;
n = n_elements(filena)
for i=0,n-1 do begin
	infil = filena(i)

;	Check for the presence of either time or key:
	CkTimeNkey, infil, utime, ukey, userTimes=userTim, key=key, $
			ntimes = ntimes

print,usertim
;	Get the Nearest New Orbit pointer to input times:
	GetNarOrb, infil, userTim, NewOrb_p, iNewOrb, len
print,infil,usertim,neworb_p 
;	Convert times to -32-byte offset:
	TimToOff, iNewOrb, NewOrb_p, len, logRecPtr1, logRecPtr2
;
	logRecPtr1=long(logRecPtr1)
        logRecPtr2=long(logRecPtr2)
	RdObsDat, infil, which, logRecPtr1, logRecPtr2, ukey, key=key, $
		maxLogRec=maxLogRec, fid=fid, sxtp=sxtp, $
		sxtf=sxtf, hxt=hxt, wbs=wbs, bcs=bcs
;	STOP, '**** GETOBSDAT before TrimTim call ****'
;	Final time check: Search all extracted data and compare with
;	User input times (userTim).
;	TrimTim, ntimes, userTim, ukey, fid=fid, sxtp=sxtp, sxtf=sxtf, $
			; bcs=bcs, hxt=hxt, wbs=wbs
end

END
