	PRO fidmap, key=key, fid=fid, sxtp=sxtp, sxtf=sxtf, $
		bcs=bcs,hxt=hxt,wbs=wbs, times=times, w=w, map=map
;	-----------------------------------------------------------
;+							15-Oct-91
;	Name:
;		fidmap
;	Purpose:
;		Create a record (map) of the observing log search
;		requests and successes.
;	CALLING SEQUENCE:
;		FIDmap, [key=key, fid=fid, sxtp=sxtp, sxtf=sxtf,
;			bcs=bcs,hxt=hxt,wbs=wbs, times=times, w=w, map=map]
;	INPUT/keyword:
;		key	user requested search keys
;		times	user requested start and stop times
;		w	Instrument selection via file prefix
;		fid	file IDs data-vector
;		sxtp	partial frame data-vector
;		sxtf	full frame data-vector
;		bcs 	bcs data-vector
;		hxt	hxt data-vector
;		wbs	wbs data-vector
;	Output/keyword:
;		map 	housekeeping data in structure form:
;			search keys, input times, instrument
;			selections, file Ids, and lists of 
;			start and stop indices for data-vectors
;			corresponding to each file id.
;	History:
;		written 19-June-91 by GAL
;		update 24-June-91
;		update 15-Oct-91, to call StENidx.pro instead of 
;			Timidx.pro and to use bcs, hxt and wbs instead
;			of oth3...
;-
;	-----------------------------------------------------------  
;	ON_ERROR, 2 	;force a return to caller if error occurs

	help,map
	IF (NOT KEYWORD_SET(map)) THEN BEGIN
	  mapTemp = "{dummy,key:' ', usrst:' ', " $
		+ " usren:' ', nfid:fix(0), w:' ', fid:' ', " $
		+ " fstat:' ', stbda:' ', enbda:' ', sthda:' ', " $
		+ " enhda:' ', stsfr:' ', ensfr:' ', stspr:' ', " $
		+ " enspr:' ', stwda:' ', enwda:' '}"
	  map = MAKE_STR(mapTemp)
	ENDIF

;	Load search key information (should "time" be appended?):
	IF (KEYWORD_SET(times)) THEN BEGIN
	  Int2ex, times.time, times.day, usrt
	  map.usrst = Arr2Str(usrt(*,0), delimitor=' ')	;user start time
	  map.usren = Arr2Str(usrt(*,1), delimitor=' ')
	ENDIF 

	map.key = STRTRIM(key)		;trim and load search key

;	Load number of files, w (with file prefix) and file names:
	nfid = N_ELEMENTS(fid)
	map.nfid = fix(nfid)			;load number file ids
	
	IF (NOT KEYWORD_SET(w)) THEN BEGIN	;default values
	  w = 'bda/sfr/spr'			;stuff oth3 into bcs
	  w = replicate(w, nfid) 
	  w = Arr2str(w)
	  map.w = w				;load file prefix
	ENDIF ELSE BEGIN
	  map.w = w				;load file prefix
	ENDELSE

	fileid = STRING(fid.ST$fileID)
	map.fid = Arr2Str(fileid)		;load file IDs

;	Load start and end data-indices: 
	IF (KEYWORD_SET(sxtf)) THEN BEGIN	;if defined
	  a = StEnidx(fid,sxtf)
	  map.stsfr =  Arr2Str(a(0,*))		;load starts
	  map.ensfr =  Arr2Str(a(1,*))		;load ends
	ENDIF

	IF (KEYWORD_SET(sxtp)) THEN BEGIN
	  a  = StEnidx(fid,sxtp)
	  map.stspr = Arr2Str(a(0,*)) 
	  map.enspr = Arr2Str(a(1,*))
	ENDIF

	IF (KEYWORD_SET(bcs)) THEN BEGIN
	  a = StEnidx(fid,bcs)
	  map.stoth3 = Arr2Str(a(0,*))
	  map.enoth3 = Arr2Str(a(1,*))
	ENDIF

	IF (KEYWORD_SET(hxt)) THEN BEGIN
	  a = StEnidx(fid,hxt)
	  map.stoth3 = Arr2Str(a(0,*))
	  map.enoth3 = Arr2Str(a(1,*))
	ENDIF

	IF (KEYWORD_SET(wbs)) THEN BEGIN
	  a = StEnidx(fid,wbs)
	  map.stoth3 = Arr2Str(a(0,*))
	  map.enoth3 = Arr2Str(a(1,*))
	ENDIF

	RETURN
	END 

