> I need a VFP command which will dump the results of a search command
> into a
> file. My program needs to look for any file meeting the DOS criteria
> XFER*.DBF. These files could be in any subdirectory. THE DOS command
> to
> do it would be:
>
> DIR XFER*.DBF >FILELIST.TXT /S
I'll let you test & debug this code for me (I haven't):
declare laFiles(1)
laFiles = ""
m.lnFound = FindFiles("laFiles","XFER*.DBF")
wait window "Found "+alltrim(str(m.lnFound))+" files matching XFER*.DBF"
procedure FindFiles
LParameter lcArray, lcFileSpec, lcDirectory
* Validate the parameters
if type("m.lcDirectory") # "C"
m.lcDirectory = ""
endif
if (not empty(m.lcDirectory)) and ;
right(m.lcDirectory) # ":" and ;
right(m.lcDirectory) # "\"
m.lcDirectory = m.lcDirectory + "\"
endif
if type("m.lcFileSpec") # "C" or ;
empty(m.lcFileSpec)
m.lcFileSpec = ""
endif
if type("m.lcArray") # "C" or ;
empty(m.lcArray) or ;
type(m.lcArray+"(1,1)") # "C"
return
endif
* Add the current directory
private lnFound, laThisDir, lcFile
m.lnFound = adir(m.lcDirectory+m.lcFileSpec,laThisDir)
if m.lnFound # 0
for m.lnFound = 1 to alen(laThisDir,1)
if empty(&lcArray.(1,1))
declare &lcArray(alen(&lcArray)+1)
endif
&lcArray(alen(&lcArray)) = m.lcDirectory + laThisDir(m.lnFound,1)
endfor
endif
* Search the SubDirectories
m.lnFound = adir(m.lcDirectory+"*.*",laThisDir,"D")
if m.lnFound # 0
=FindFiles( (m.lcArray), (m.lcFileSpec), (laThisDir(m.lnFound,1)) )
endif
* Return the results
if empty(&lcArray.(1,1))
return 0
else
return alen(&lcArray)
endif