function getdatfiles,widgetid,filesel=filesel
	widget_control,widgetid,get_uvalue=pstateinspectrun
	echofilesno=fix(strmid((*(*pstateinspectrun).ptr_echofiles) ,1,4))
	filesno=n_elements((*(*pstateinspectrun).ptr_echofiles))
	longdatfiles=file_search((*pstateinspectrun).pathdir+'SingleTimes/m' $
		+strtrim(string(echofilesno(filesel)),2)+'*_*.dat')
	pathdirlength=strlen((*pstateinspectrun).pathdir)
	datfiles=strmid(longdatfiles,pathdirlength+12)
	if (datfiles(0) ne '') then begin
		nodatfiles=n_elements(longdatfiles)
		nftxdat=intarr(nodatfiles)
		posftxdat=strarr(nodatfiles)
		strft_files=''
		strft_files_pos=''
		strft=''
		dummystr=''
		for i=0,(nodatfiles-1) do begin
			openr,unit,longdatfiles(i),/get_lun
			nlines = fix(file_lines(longdatfiles(i)))
			line=strarr(nlines)
			readf,unit,line
			free_lun,unit
			nftxdat(i)=n_elements(where(strmatch(line,'fouriertime*') eq 1))
			posftxdat(i)=strjoin(string(where(strmatch(line,'fouriertime*') eq 1)))
			temparray=intarr(nftxdat(i))
			temparray=fix(strsplit(posftxdat(i),/extract))
			for j=0,(nftxdat(i)-1) do begin
				reads,line(temparray(j)),format='(A11,e12.5,e12.5)',dummystr,time1,time2
				strft=strft+string((time1+time2)/2)
				strft_files=strft_files+string(i)
				strft_files_pos=strft_files_pos+string(j)
				reads,line(temparray(j)+1),format='(A11,f12,f12,A2,f)',dummystr,dummy,dummy,dummystr,q
			end ; j
			ft=float(strsplit(strft,/extract))
			ft_files=fix(strsplit(strft_files,/extract))
			ft_files_pos=fix(strsplit(strft_files_pos,/extract))
		end ; i

		ftorder=sort(ft)
	endif else begin
		ft=!values.f_NaN
		ftorder=0
		q=!values.f_NaN
		ft_files=!values.f_NaN
		nftxdat=!values.f_NaN
		posftxdat=''
		ft_files_pos=!values.f_NaN
	end ; no dat files

	datfilesstr={datfiles:datfiles, ft:ft, ftorder:ftorder, $
			q:q, nftxdat:nftxdat, posftxdat:posftxdat, $
			ft_files:ft_files,ft_files_pos:ft_files_pos}
return,datfilesstr
end ; getdatfiles
