	PRO fidmap, key=key, fid=fid, sxtp=sxtp, sxtf=sxtf, $
		oth3=oth3, times=times, which=which, map=map
;	-----------------------------------------------------------
;+							24-June-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,
;			oth3=oth3, times=times, which=which, 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
;		oth3	other 3 intru. 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
;-
;	-----------------------------------------------------------  
;	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(which)) THEN BEGIN	;default values
	  w = 'bda/sfr/spr'			;stuff oth3 into bcs
	  w = replicate(which, nfid) 
	  w = Arr2str(which)
	  map.w = which				;load file prefix
	ENDIF ELSE BEGIN
	  map.w = which				;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
	  stsfr = timidx(fid,sxtf)
	  nst = N_ELEments(stsfr)
	  ensfr = stsfr
	  ensfr(0) = stsfr(1:*)-1	
	  ensfr(nst-1) = N_Elements(sxtf)-1	;last entry
	  map.stsfr =  Arr2Str(stsfr)
	  map.ensfr = Arr2Str(ensfr)
	ENDIF

	IF (KEYWORD_SET(sxtp)) THEN BEGIN
	  stspr = timidx(fid,sxtp)
	  nst = N_Elements(stspr)
	  enspr = stspr
	  enspr(0) = stspr(1:*)-1
	  enspr(nst-1) = N_Elements(sxtp)-1	;last entry
	  map.stspr = Arr2Str(stspr) 
	  map.enspr = Arr2Str(enspr)
	ENDIF

	IF (KEYWORD_SET(oth3)) THEN BEGIN
	  stoth3 = timidx(fid,oth3)
	  nst = N_Elements(stoth3)
	  enoth3 = stoth3
	  enoth3(0) = stoth3(1:*)-1
	  enoth3(nst-1) = N_Elements(oth3)-1	;last entry
	  map.stoth3 = Arr2Str(stoth3)
	  map.enoth3 = Arr2Str(enoth3)
	ENDIF

	RETURN
	END 
