17 Июль 2008 г.

Repair DBF structure (if damaged file header)

SET TABLEVALIDATE TO 3
CD "C:\Repair\"

OPEN DATABASE osago EXCLUSIVE
VALIDATE DATABASE TO FILE before.txt

lnDBF = ADIR(laDBF,"*.dbf")
FOR i = 1 TO lnDBF
  TRY
  USE (laDBF[i,1]) EXCLUSIVE
  CATCH
  SET TABLEVALIDATE TO 0
  USE (laDBF[i,1]) EXCLUSIVE

  MESSAGEBOX("Table "+laDBF[i,1]+" could not be opened. "+CHR(13)+;
  "Please delete any damaged records (Ctrl-T). "+CHR(13)+;
  "Press Ctrl-W when finished",16)

  BROWSE
  SET TABLEVALIDATE TO 3
  FINALLY
  PACK
  REINDEX
  ENDTRY
NEXT
VALIDATE DATABASE RECOVER TO FILE after.txt