subroutine Select_Files(ok)
use work

use dfwin
use dflib


character(800) :: file_spec = ""C
character(max_path) lpstrInitialDir ,lpstrFilter, lpstrTitle, &
					lpstrDefExt, lpstrFile*800
integer nFilterIndex
character(max_path) CurrentDirectory; integer istat
integer status
integer lenCurr

character(3) i_char
integer(1) extr1(n_ext)

logical ok

character(800) fname_all
integer(2) nFileOffset

character(1) null_char/''C/, char_1, char_1_ant

integer sep(800)



lpstrInitialDir =""C	!NULL
lpstrFilter = &
  "Text Files (*.txt)"C//"*.txt"C//&
  "Data Files (*.dat)"C//"*.dat"C// &
  "All files (*.*)"C//"*.*"C//""C

!lpstrTitle ='Selecteaza Fisierul de extrageri REALE'C

nFilterIndex =1
lpstrDefExt ='txt'C
lpstrFile ="*.txt"C	!""C


! OpenFile:
istat =GetCurrentDirectory(max_path, CurrentDirectory)
if(istat >0) then
lpstrInitialDir =CurrentDirectory
endif




lpstrTitle ='Selecteaza Fisierele de extrageri'//''C

call SelectFile(lpstrInitialDir ,lpstrFilter, lpstrTitle, nFilterIndex, &
					lpstrDefExt, lpstrFile, status, nFileOffset, nMaxFile)

ok =status >0


! Fisierul total:
!*
write(11, '(a)') lpstrFile
!*

fname_all =lpstrfile(nFileOffset +1:)

write(11, '(I)') nFileOffset

write(11, '(a)') fname_all

!Numara fisierele:
no_of_files =0
isep =1

sep =0

do ichar =1, nMaxFile

char_1 =fname_all(ichar:ichar)

if(char_1 ==null_char) then
isep =isep+1
sep(isep) =ichar

	if(sep(isep) -sep(isep-1) /=1) then
!	fname(isep) = fname_all(sep(isep-1)+1:sep(isep))
	
	no_of_files =no_of_files+1
	fname(no_of_files) = fname_all(sep(isep-1)+1:sep(isep))

!	li =lstrlen(fname(isep))
!	write(11,*) fname(isep)(:li)
	endif
endif

enddo

write(11, '(I)') no_of_files

END subroutine Select_Files
