Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

A tool for repairing DBF Visual Fox Pro databases

dbf


  • Please log in to reply

#1
EvGreene

EvGreene

    New Member

  • Member
  • Pip
  • 1 posts
HI
 
I need to repair some DBF files created by VIsual Fox Pro, I wonder if there is a free tool to do it ? or If this could be possible using VFP 9 ?
 
Thanks in advance.

  • 0

Advertisements


#2
azarl

azarl

    GeekU Admin

  • Community Leader
  • 25,310 posts

Try this prog on a copy of the file
 
 

RepairHeader('c:\SomePath\mytable.dbf')

Function RepairHeader
Lparameters tcDBF
Local handle, lnFileSize, lnReccount, lnHeaderSize, lnRecordSize, ;
lnCalculatedReccount, llHasMemo
handle=fopen(tcDBF,12) && Opened readwrite
lnFileSize = fseek(handle,0,2) && Get file size
* Read header info
lnReccount = ReadBytes(handle, 4,4)
lnHeaderSize = ReadBytes(handle, 8,2)
lnRecordSize = ReadBytes(handle,10,2)

lnCalculatedReccount = floor((lnFileSize-lnHeaderSize)/lnRecordSize)
If lnCalculatedReccount # lnReccount && If calculated # recorded fix it
WriteBytes(handle, 4,4,lnCalculatedReccount)
Endif
=fclose(handle)

function WriteBytes
Lparameters tnHandle, tnPos, tnSize, tnNumber, tlLR
Local lcString, lnLowDword, lnHighDword,ix
lcString=''
If tlLR
For ix=tnSize-1 to 0 step -1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Else
For ix=0 to tnSize-1
lcString=lcString+chr(tnNumber/256^ix%256)
Endfor
Endif
=fseek(tnHandle, tnPos,0) && Go to Pos
Return fwrite(tnHandle,lcString)

function ReadBytes
Lparameters tnHandle, tnPos, tnSize, tlLR
Local lcString, lnRetValue,ix
=fseek(tnHandle, tnPos,0) && Go to Pos
lcString = fread(tnHandle, tnSize) && Read tnSize bytes
lnRetValue = 0
For ix=0 to tnSize-1 && Convert to a number
lnRetValue = lnRetValue + asc(substr(lcString,ix+1)) * ;
iif(tlLR,256^(tnSize-1-ix),256^ix)
Endfor
Return int(lnRetValue


  • 0






Similar Topics


Also tagged with one or more of these keywords: dbf

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP