Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A Fox command dos's DIR MYFILE.TXT >FILELIST.TXT /S
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00043406
Message ID:
00043867
Views:
41
After I wrote this reponse to Paul, I figured what lathisdir is. Pls disregard, Paul, and I will post your code after I debug it. I see where you're going now, and know it took some serious time. I am VERY thankful. I know it will work, which is much farther than I was before. It's going to take a bit of tweeking, though.

JR

>Yikes, Paul--looks like you spent some time on this one. I really appreciate it. I see why you need it, as ADIR alone doesn't yield directory names, which is what I need.
>
>I'm debugging (and will post the results to you and the others who responded), but I've got a question--I don't know where you're going with the laThisDir variable. You private it, then use it in the next line in your
>
>m.lnFound = adir(m.lcDirectory+m.lcFileSpec, laThisDir)
>
>line. at first, the m.lcDirectory variable is [] (or ""), and the file spec is [xfer*.dbf]. The syntax of adir needs the array name first, followed by the filespec, followed by the attributes. I'm assuming that the array name can be anything (I haven't gone much farther than this, so I may need to name it something specific, but that's beside the point). However, the laThisDir baffles me. Should that be a [D]? It's used later in your code, but I don't understand how.
>
>Thanks again.
>JR
>
>>> 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
CLARC Services, Inc.
3500 Tamiami Trail
Port Charlotte, FL 33952
www.clarc.com
(941) 743-0108
(800) 246-5488
Previous
Reply
Map
View

Click here to load this message in the networking platform