Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Memo file missing or invalid.
Message
De
01/05/2001 02:56:24
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
30/04/2001 19:08:55
Jordan Pastourel
Worksafe Management Systems
Toowong, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00501828
Message ID:
00501872
Vues:
17
>Hi all,
>i have a client who is getting the "memo file is missing or invalid" error in their system. which is all well and good as i now know that the problem lies in the .fpt file....... but how do i recover it?? i can't seem to find anything in the help for it. am i going blind with the answer right infront of me??
>
>Jordan

Jordan,
You could use this routine for a quick fix :
define class RM as relation
Procedure RepairMemo
  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 - Stored in left-to-right format
    lnNextBlockPointer = .ReadBytes(handle, 0,4,.T.)
    lnBlockSize  = .ReadBytes(handle, 6,2,.T.) 

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

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)
Endfunc

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)
Endfunc
enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform