* Loop through current folder to find bad dbf * files by trying to open each. Log failures. CLEAR LOCAL lnBadCount, lcTable, loError lnBadCount = 0 *Grabs first DBF lcTable = SYS(2000,"*.DBF") DO WHILE NOT m.lcTable == "" TRY USE (m.lcTable) IN 0 ALIAS thisDbf USE IN SELECT("thisDbf") CATCH TO loError ? "Table " + m.lcTable + " is bad." lnBadCount = m.lnBadCount + 1 ENDTRY *Grabs NEXT DBF lcTable = SYS(2000,"*.DBF",1) ENDDO * Tell the user how it went ? IIF(m.lnBadCount = 0, "No errors.", TRANSFORM(m.lnBadCount) + " table(s) could not be opened.")>I have used this type of solution before in a stand-alone PRG for testing tables (untested code):
>PUBLIC nCount, gnDbcnumber, gaDatabase[1], gnBadCount > >* Redirect our error handler to display relevant information >ON ERROR DO flagError WITH gaDatabase[nCount, 1] > >* Get directory of all DBF files >gnDbcnumber = ADIR(gaDatabase, '*.DBF') > >* Loop for number of tables to find bad ones >gnBadCount = 0 >FOR nCount = 1 TO gnDbcnumber > * Try to open it > USE (gaDatabase[nCount, 1]) IN 0 ALIAS thisDbf > > * If it opened, close it > IF USED("thisDbf") > USE IN thisDbf > ENDIF >NEXT > >* Restore our error handler >ON ERROR > >* Tell the user how it went >? IIF(gnBadCount = 0, "No errors", TRANSFORM(gnBadCount) + " tables could not be opened") > > >FUNCTION flagError >LPARAMETERS pcTable > * Note: you could add additional passed parameters to verify the error message, etc. > ? "Table " + pcTable + " is bad" > gnBadCount = gnBadCount + 1 >