Selim Yucel


Hello,
I have a DBF file an I need to open it. I have VFP9.0 and when I try to open it I get a message suc as:

"Memo file C:\....\myfile.fpt is missing or is invalid."

Is there a way to open this file
I will deeply appreciate advices or ideas..
Thanks.




Re: Memo file is missing or invalid

Cindy Winegarden


Hi Selim,

You may lose/have lost all the information in your Memo fields.

One way to get the table to open is to create another table with one field for each Memo column in your problem table, named with the same names as your table. After you create your table, don't add any records. Close it. Rename the FPT file with the same name as your problem table. After this you should be able to open the problem table.

As always, make a backup before doing this process so if you create more problems you can go back to what you had.

Often this type of Memo corruption comes from shutting down a computer when the table is open. This can be due to an unreliable network or a user. Beef up the network and educate the users to close out of the app before they turn off their computers, as appropriate.







Re: Memo file is missing or invalid

CetinBasoz

Selim,
You might also recover your memo file if problem is in next memo block pointer (get a backup and use at your own risk - yani sorumluluk kabul etmem:)

close data all
m.lcDBF = "c:\mypath\myTable.dbf"
RepairMemo(Forceext(m.lcDBF,'FPT'))

Function RepairMemo
  * RepairMemo
  * Simply fixes next block pointer, blocksize and filesize
  Lparameters tcMemoFilename
  Local handle, lnFileSize, lnNextBlockPointer, lnBlockSize, lnFirstBlock, lnCalculatedFileSize

  handle=Fopen(tcMemoFilename,12) && Opened readwrite
  lnFileSize = Fseek(handle,0,2) && Get file size
  With This
    * Read header info
    lnNextBlockPointer = ReadBytes(handle, 0,4,.T.) && Stored in left-to-right format
    lnBlockSize        = ReadBytes(handle, 6,2,.T.) && Stored in left-to-right format

    * Specific to me - no blocksize setting to something other than default 0x40
    If lnBlockSize # 0x40
      WriteBytes(handle, 6,2,0x40,.T.)
      lnBlockSize=0x40
    Endif
    *

    lnFirstBlock    = Ceiling(512/lnBlockSize) && Possible min lnNextblockpointer
    lnCalculatedFileSize = lnNextBlockPointer*lnBlockSize

    * Fix if needs repair
    If !(lnFileSize >= 512 ;
        and lnNextBlockPointer >= lnFirstBlock ;
        and lnCalculatedFileSize >= lnFileSize) && Memo needs repair
      lnNextBlockPointer = Max(lnNextBlockPointer, lnFirstBlock)
      lnFileSize = lnNextBlockPointer * lnBlockSize
      WriteBytes(handle, 0,4,lnNextBlockPointer,.T.) && Fix next block pointer
      =Fchsize(handle, lnFileSize) && Fix filesize
    Endif
  Endwith
  =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)






Re: Memo file is missing or invalid

Selim Yucel

Thanks for the advices.
I downloded one of those repairing softwares and opened darn file.
Best Regards




Re: Memo file is missing or invalid

Mark Milan

Hi Cindy,

Apologize for my english. My question is: How if I don't know the exact name of the column table. It happens that he shared me a .dbf file but I can't open it, "Memo file is missing or invalid." And I dnt have any idea what is memo column or structure of the table. Please help.

Thanks.





Re: Memo file is missing or invalid

slarin

Did he gave you the .FPT file also





Re: Memo file is missing or invalid

Mark Milan

Hi slarin,

No he didnt give the .fpt file, but I solved my problem already, I used dbf recovery trial, and then from there I saw the structure of the table (memo), then I followed cindy's instruction. TY. Thanks also cindy.

Mark