INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Databases and tables

Remove dbc reference by program by rob444
Posted: 25 Oct 03

*** 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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close