Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove dbc reference by program

Databases and tables

Remove dbc reference by program

by  rob444  Posted    (Edited  )
*** Sometimes it might be easy to remove dbc references in tables with a program.
*** Here it is.


* ClearDBCRef.prg
close all
set safe off

dimension dbfhdr[32]
cInfile=space(30)
CLEAR
@ 5,5 say 'Name DBF with extention ' get cInfile
READ
cInfile = ALLTRIM(cInfile)
STORE FOPEN(cInfile,12) TO fh && Open the file readwrite
DO readheader

nFirstRefByte = dbfhdr[9]+dbfhdr[10]*256 - 263

* jump to byte 'END OF HEADER', 0x0d
=FSEEK(fh,nFirstRefByte-1,0)
* check End Of Header byte
nEOHbyte = ASC(FREAD(fh,1))
IF nEOHbyte = 13
** write 263 '0x00' bytes
=FWRITE(fh,replicate(chr(0),263),263)
=FCLOSE(fh)
ELSE
? 'Something is wrong with the structure'
? 'The End of Header byte not found at its supposed place'
? 'No changes have been made'
ENDIF
RETURN

procedure readheader
=FSEEK(fh, 0,0) && Move pointer to first byte
nbytecount=1
do while nbytecount < 33
dbfhdr[nbytecount] = ASC(fgets(fh,1))
nbytecount=nbytecount+1
enddo
return
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top