Michael
>Therefore, is it possible to check whether a table is already referenced in a database, so that it can be removed if the table is missing?
To find orphan table references in the DBC you could do something like this:
OPEN DATABASE YourDBC
lnTableCount = ADBOBJECTS(laTableList,'TABLE')
FOR lnRow = 1 TO ALEN(laTableList)
IF NOT FILE( ALLTRIM(laTableList[lnRow]) + '.dbf' )
? '"' + ALLTRIM(laTableList[lnRow]) + '.dbf" does not exist.'
ENDIF
ENDFOR
CLOSE DATABASE
You would actually store the missing file names into another array or cursor. Once you have a list of orphan table references, you can then open the DBC as a dbf. In other words:
USE YourDBC.dbc
Now you can SCAN the dbc for orphan table references and DELETE them.
I suggest you have your utility make a backup copy of your dbc, dct, and dcx files before it actually starts modifying the data!
HTH
PS
If you are in the process of developing a set of database utilities, you might consider looking at Stonefield Database Toolkit. It could save you months of effort!
George Simon, MCP