CM Table Repair Utility
Version 2005b
Copyright (c) 1995-2005 CompuMotor Company, Sofia, Bulgaria.
All Rights Reserved.
Support site: www.cmstory.com

============================

DESCRIPTION

Check and repair utility for Visual FoxPro, FoxPro and other DBF tables. You can see and repair nearly all items in the header and structure of the table and memo files. It can be called from code to automatically repair bad headers.


REGISTRATION

Unregistered version is for testing purposes and works in development environment only. To use this utility you need to obtain (purchase) registered copy. Please contact through support web site (or send a message) and we will sent to you further details and license conditions. With registered version you can use full capacity of the utility, can include it in your end user software product to distribute in this way to your end users.


REQUIREMENTS

Application consists from one run-time file: cmrepair.app. This is a Visual FoxPro application, so you need VFP installed on your system. It was tested with VFP 7, 8 and 9. It should work with VFP 6, but we are not testing our applications with this version of VFP any more.


WARNING

Please backup data before repairing. This utility can write in the tables and memo files at low level, so be careful.


WARRANTY

This program is provided "as is" without any kind of warranty. The author doesn't take any responsibilities for any damages or data loss.


MORE NOTES

It is well known, that if a FoxPro program (any version) appends/writes to a table and computer crashes, the table becomes bad (corrupted). Next time when FoxPro tries to open it, an error appears, like:

For several years of working with many and large data massifs, we discovered that in 99 % it is possible to recover tables and memo files with small or no loss of information.

One of the problems occurs when FoxPro appends records. FoxPro engine writes buffers on disk in this order: first changes record number in the header of the table, and afterwards changes the size of the files and writes data. Better way is to reverse order of this two operations, but it is embedded in the Foxpro engine.

We are using this utility with success a lot of years.
Any comments, ideas, suggestions and bug reports are appreciated. Please send them through support web site (or send a message).
 

EXAMPLES FOR USAGE

In package are included 2 PRG files, example_1table.prg and example_1folder.prg. You can explore and run them in Visual Foxpro to see how CM Table Repair works. You can also run directly cmrepair.app. Here are more examples to call cmrepair.app.

For testing purposes in sub-folder bad_dbf some damaged tables are included.


CALLING PARAMETERS DESCRIPTION
 
Place Parameter Type Compulsory Defaults to Description
1 cPathName input no "" Variant 1. Valid table (full path and name) - table to check and repair.
Variant 2. Valid directory (full path with end slash) - folder to check or default directory for selection of table to check.
If empty - user manually have to select table for the checking.
2 lAutoChange input no .f. If .t. - auto-repair mode. Repairs corrupted table and memo files of the given table with cPathName.
3 nAutoRiskRecords input no 5 Specifies how many records maximum can be truncated in auto-repair mode, or so called "risk records".
4 cPathNameLogFile input no AddBS(JustPath(SYS(16,0))) + "cmrepair.log" Path and name of the log file to record any activity in auto-repair mode. If the file does not exists, it will be created first time CM Table Repair needs to write in it. If not given - default place for it is in same folder as main calling program.
5 tlSilence input no .f. If .t. - silence mode, no messages and no interface in auto-repair mode. You can get result info from a_TableCheckInfo and other output parameters.
6 tnTablesToCheck output no 0 How many tables are given to check in auto-repair mode.
Equals to 1 if a file is given to be checked, and,
number of tables in the given folder if folder is given to be checked (or equals to ALEN(a_TableCheckInfo,1)).
7 tnTablesChecked output no 0 How many tables are checked from the given to check in auto-repair mode.
8 tnTablesCorrupted output no 0 How many tables are corrupted from the checked tables in auto-repair mode.
9 tnTablesAutoRepaired output no 0 How many tables are auto-repaired from the corrupted tables in auto-repair mode.
10 a_TableCheckInfo output no array[tnTablesToCheck,5] Array with info for tables given  to be checked.
a_TableCheckInfo[n,1] - name of the table
a_TableCheckInfo[n,2] - .t. if checked
a_TableCheckInfo[n,3] - .t. if corrupted
a_TableCheckInfo[n,4] - .t. if auto-repaired
a_TableCheckInfo[n,5] - messages, if any.
11 tlAutoBackup input
output
no .f. If to make backup copy of table files before repairing. In auot-repair mode here on output - if backup is really created. Backup name is same as original table name, with "-backup" added (before extension dot).


HISTORY SINCE THE UTILITY IS PUBLISHED
 

Version Date Changes
  1995
  • First Foxpro 2.6 versions.
  1999
  • First Visual Foxpro version (VFP 6).
  1999-07-09
  • Some interface changes and users suggestions.
  2000-11-15
  • bugs removed (no more errors in case of any file checking)
  • some long file name problems decided
  2002-12-08
  • Upgrading and support for VFP 7
2003a 2003-11-28
  • Added support for auto-incrementing in tables
  • Upgrading and support for VFP 8
  • Changes and improvements
2004a 2004-06-19
  • Added support for new data types
  • Upgrading and support for VFP 9
  • Removed limitation for number of records in advanced memo file analysis in case of running with VFP 9
2004b 2004-07-28
  • Auto-repair mode now repairs both record numbers and file size
  • Activity in auto-repair mode logs to a file with same folder and name as the utility, with .log extension
  • Introduced is new (third) calling parameter: number of risk records in auto-repair mode (defaults to 5)
2004c 2004-08-27
  • Auto-repair mode now repairs memo file headers in case of error 41 "memo file invalid" (next free block number and block size)
  • More precise handling of memo file checking process and offer to change memo file attributes
  • Checking given folder for corrupted tables, both manual and auto-repair mode
  • Introduced is new (fourth) calling parameter: path and name of log file for auto-repair activity
  • Introduced is new (fifth) calling parameter: silence mode (if .t.)
  • Introduced are new output parameters: info for performed work in auto-repair mode
  • Save and restore last directory where checking is performed (if not file or folder given as parameter)
  • Different style of starting: first screen appears, afterwards opening the table to check
  • Bugs are removed (refreshing in window "Memo file analyzing", appearing of the interface in auto-repair mode in case of not damaged table)
  • Improved documentation
2004d 2004-12-13
  • Some small bugs are removed
  • More support of SET TABLEVALIDATE command in auto-repair mode
  • In auto-repair mode, when the interface appears, information is shown about the reason

 

2005a 2005-07-04
  • Introduced is possibility to fix the problem if repaired table exceeds 2 Gb (the Foxpro limit) and becomes corrupted (that happens for example when error 1190 "File is too large" is not triggered in VFP7 and below).
  • Removed dependence on foxtools.fll. If you are using old versions of VFP (<7), please set library to foxtools.fll in advance.
  • Support for all known Foxpro table types: DBF, FRX, LBX, DBC, SCX, VCX, MNX, PJX and respective memo files.
  • Auto-backup parameter and separate button (parameter is 11-th and defaults to .f.!)
  • All reported bugs to the moment are removed
  • More interface improvements
  • Stand alone EXE version (for registered users only)
2005b in progress
  • Handling of error 13 (Alias is not found) when opening table in folder checking procedure. This error occurs if a table alias is used in index expression in CDX file, but not exist at that moment.
  • In case of folder checking all files with known table extensions are included in the process. The user can edit extensions list.
  • Example function for checking given folder in auto-repair mode with displaying the result.