	Function DsetVec, fnMap=fnMap, tsxtf=tsxtf, tsxtp=tsxtp, $
		toth3=toth3, dsxtf=dsxtf, dsxtp=dsxtp, doth3=doth3
;	-----------------------------------------------------------
;+							28-June-91
;	NAME:
;		DsetVec
;	Purpose:
;		For each "fnMap" request convert the input data-
;		time vectors to roadmap-index vectors.
;	CALLING SEQUENCE:
;		err = DsetVec([fnMap=fnMap, tsxtf=tsxtf, tsxtp=tsxtp,
;			toth3=toth3, dsxtf=dsxtf, dsxtp=dsxtp,
;			[B
;	Input/Keyword:
;		fnMap	record of the users request for data.
;		tsxtf	list of specific requested times
;		tsxtp	list of specific requested times
;		toth3	list of specific requested times
;	Output/Keyword:
;		dsxtf	list of roadmap-index values (0 to n-1)
;		dsxtp	list of roadmap-index values
;		doth3	list of roadmap-index values
;	History:
;		written 28-June-91 by GAL
;-
;	---------------------------------------------------------
;	ON_ERROR, 2 	;force a return to caller on error

;	Define new Data-set vectors:
	IF (KEYWORD_SET(tsxtf)) THEN BEGIN
	  dsxtf = tsxtf.time	;define dimensions an data-type
	  dsxtf(*) = LONG(0)	;initialize values
help,sdsxtf
	ENDIF
	IF (KEYWORD_SET(tsxtp)) THEN BEGIN
	  dsxtp = tsxtp.time
	  dsxtp(*) = LONG(0)
	ENDIF
	IF (KEYWORD_SET(toth3)) THEN BEGIN
	  doth3 = toth3.time
	  doth3(*) = LONG(0)
	ENDIF

	fileType = ['bda','hda','sfr','spr','wda']	;valid types
	nftypes = N_ELEMENTS(fileType)

	fstat = Str2Arr(fnmap.fstat)	;this can be slow if long
	dolist = WHERE(fstat eq '1')	;list of located files

	IF (dolist(0) eq -1) THEN BEGIN
	  Print, '*** DsetVec-- None of the following files were',$
		+' located:'
	  Print, format='(a)', fnMap.fileNa
	  RETURN, 0			;return with error flag
	ENDIF

	ndo = N_ELEMENTS(dolist)	;total number of files todo
	fileNa = Str2Arr(fnMap.fileNa)
help,filna
	FOR i=0, ndo-1 DO BEGIN		;for all located files
	  found = 0			;prefix find flag set to false
	  j = 0 			;initialize prefix loop
	  prefixValid =1		;assume file has valid prefix
	  WHILE (NOT found) DO BEGIN
	    ck = StrPos(fileNa(dolist(i)),fileType(j))
	    IF (ck ne -1) THEN BEGIN 	;the file-type is know
	      found = 1			;exit loop
	    ENDIF ELSE BEGIN
	      IF ((j+1) eq nftypes) THEN BEGIN	;no valid file prefix
		prefixValid = 0		;set file prefix status to false
		Print, '*** DsetVec-- No valid file prefix found for' 
		Print, 'File: ', fileNa(dolist(i))
	        found = 1			;exit loop	;MDM ADDED
              ENDIF ELSE BEGIN
		j = j + 1		;increment to next 
	      ENDELSE
	    ENDELSE
	  ENDWHILE

	  IF (prefixValid) THEN BEGIN
	    CASE fileType(j) OF	;OPEN FILE and Define data vectors:
	      'bda': BEGIN
        ;MDM           Print, '*** Sorry BDA Access is Not available yet'
	;	       fnMap.fStat(doList(i)) = 0	;change from T to False
		     END
              'hda': BEGIN
                       Print, '*** Sorry HDA Access is Not available yet'
	;	       fnMap.fStat(doList(i)) = 0	;change from T to False	
	             END
	      'spr': BEGIN
;if n_elements(tsxtp) ne 0 then begin		;MDM
if get_nbytes(tsxtp) gt 2 then begin
		       stidx = LONG(StrMap(fnmap.nfiles,fnmap.stspr,doList(i)))		;MDM removed>0
		       enidx = LONG(StrMap(fnmap.nfiles,fnmap.enspr,doList(i)))		;>0
			;MDM added check to see if any valid data for that file
		       if (stidx ne -1) then begin
				time = tsxtp(stidx:enidx)
				err1 = GetSDAVec(fileNa(doList(i)), time, stidx, dSet=dsxtp)		      
			end
;		       may want to look at error flag???
endif
		     END
	      'sfr': BEGIN
		       stidx = LONG(StrMap(fnmap.nfiles,fnmap.stsfr,doList(i)))	;MDM removed >0
		       enidx = LONG(StrMap(fnmap.nfiles,fnmap.ensfr,doList(i)))	;MDM removed >0
			;MDM added check to see if any valid data for that file
		       if (stidx ne -1) then begin
				;;print, filena(dolist(i)), stidx, enidx		& in=' ' & read,'Pause',in 
		      		time = tsxtf(stidx:enidx)
				err1 = GetSDAVec(fileNa(doList(i)), time, stidx, dSet=dsxtf)
			end
;		       may want to look at error flag???
		     END
	      'wda': BEGIN
                       Print, '*** Sorry WDA Access is Not available yet'
		       fnMap.fStat(doList(i)) = 0	;change from T to False	
		     END
	      ELSE:  BEGIN
                       Print, '*** Sorry Access to ', fileNa(doList(i)), $
			'File is Not available yet'
		       fnMap.fStat(doList(i)) = 0	;change from T to False	
		   END
	  ENDCASE

	  ENDIF
	ENDFOR				;end file loop

	err =1
	RETURN, err
	END	  	  
