Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile record counts on a network drive

Status
Not open for further replies.

NPSArcheologist

Technical User
Jan 26, 2007
2
US
Our network administrator has asked me to compile a total count of data records in a set of .dbfs that function as part of a proprietary, but poorly guarded, VFP 6.0 app we have running. Is there a quick way to code a small VFP app to examine X number of similarly-named (e.g. objects.dbf) files in subfolders (i.e. //6arch/objects.dbf, //6seac/objects.dbf, etc.) on a mapped network drive, count the records in the .dbfs, and add the counts to arrive at a total count of records on the drive.

By the way, the .dbf normally returns an error when opened in VFP 6.0 due to a coded .prg call added to the table index by the original programmers (don't ask, I didn't have anything to do with the design of it--and I have been told I may not change it)...
 
First of all you might want to make a copy of the files within the directory in question so that you can make a change to the problematic DBF data table's index.

To fix that file's Index, delete its CDX file, open the table and when you get a "missing CDX file" message, tell it to Ignore it.

Then if you have the directory copy made you can use one of several approaches.
One way is to write a program which can:
1. USE ADIR() to get the filenames of all the DBF files within the directory and put those names into an array
2. USE FOR/ENDFOR loop based on the number of DBF files found to open each data table and use RECCOUNT() to get the record count. Then close the data table and continue through the loop.
3. While looping through the individual data tables, sum the number of records found into a memory variable representing the over-all record count.
4. After completing the loop, report the over-all record count in some manner - on-screen, printout, etc.

Good Luck,
JRB-Bldr
 
Hi NPSArcheologist,

JRB-Bldr has given you a very complete and accurate answer. I'll just add one small point: the record count will include any records that have been flagged as deleted. If that's not what you want, you'll need to SET DELETED ON, then do COUNT(*) TO with a memory variable. This will be much slower than RECCOUNT(), but will ignore deleted records.

By the way, the fact that the files are on a network doesn't make any difference to the solution.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you both for this solution. I know that the problem may seem pretty elementary, but I have a Ph.D. in anthropology/archaeology, not programming. It is a whole new world. In any case, if I get some successful code, I'll repost for comment/use...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top