>>if empty(dbf()) >> return "" >>endif >>local lcDBC, lnRetVal, llFound, lcCurDBC, laDBCs[1] >>lnRetVal = ADATABASES(laDBCs) >>lcCurDBC = SET('database') >>FOR EACH lcDBC IN laDBCs >> SET DATABASE TO (lcDBC) >> IF INDBC(JUSTSTEM(JUSTFNAME(DBF())), 'Table') >> llFound = .t. >> EXIT >> ENDIF >>ENDFOR >>SET DATABASE TO (lcCurDBC) >>CLEAR >>if not llFound >> lcDBC = "" >>endif >>RETURN lcDBC>
if !empty(cursorgetprop("Database",lcAlias)) && Not a free table if !dbc()=cursorgetprop("Database",lcAlias) && DBC is not the current one open database (cursorgetprop("Database",lcAlias)) && Open or Set current endif *...1) A DBC is already a DBF. It has 0x04 flag set at byte offset 28 (DBC indicator) and its backlink info is empty. You can use it and modify like any DBF. But don't tkae it as I'm suggesting to do it unless you know what you're doing. It's very easy to render it useless. Also note that it keeps many things in compiled form. You should be able to compile if you modify anything that requires it (ie:stored procs) or supply a precompiled form.
* List paths of DBC tables lnObjects = adbobjects(arrDBObjects,'TABLE') for lnDbObject=1 to lnObjects ? upper(dbgetprop(arrDBObjects[lnDbObject],'TABLE','Path')) endforBelow simply demonstrates renaming a DBC (ie: 'testdata' to 'mydata'). (With the assumption DBC and its tables are in the same dir)
Function RenDbc lparameters OldName, NewName Open data (oldName) lnTables=adbobject(arrTables,'TABLE') For ix=1 to lnTables lcTable = arrTables[ix]+'.DBF' handle=fopen(lcTable,12) =fseek(handle,8,0) lnLowByte = asc(fread(handle,1)) lnHighByte = asc(fread(handle,1))*256 lnBackLinkstart = lnHighByte + lnLowByte - 263 =fseek(handle,lnBackLinkstart,0) Fwrite(handle,forceext(newName,'dbc')+replicate(chr(0),263),263) =fclose(handle) Endfor Close data all Rename (forceext(oldName,'dbc')) to (forceext(newName,'dbc')) Rename (forceext(oldName,'dcx')) to (forceext(newName,'dcx')) Rename (forceext(oldName,'dct')) to (forceext(newName,'dct'))If you were just to move DBC and tables to different locations keeping their relative pathing to each other you don't need all these. Just move/copy. During dbc opening if dbc path is not hardcoded (as in forms with DE) or if it can't find in the hardcoded path then would use the one in its search path.