Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding Offset for General Memo Field
Message
De
08/09/2003 02:29:14
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/09/2003 00:01:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00826959
Message ID:
00826978
Vues:
24
>I am trying to extract bmp from a general field however the offset must be different than the 599 that was recommend in the program file that I was able to locate on MSDN kd161832
>
>so than I tried to use the HEXEDIT.APP it would act like it was going to start be then it would close down my VFP 7.0
>
>Does anyone have any source code or a prg that would showme what the offset would be.
>
>Thanks
>
>Ken

Ken,
599 looked suspect to me too but this works :
Function savebmps
Lparameters tcTable, tcField, tnRecNo, tcOutFileName
* tcTable - Tablename containing BMP gen field
* tcField - Gen field name
* tnRecNo - recno no extract
* tcOutFileName - path and fielname of output filename

Local handle, handleout, lcTable
lcTable = "T"+Sys(2015)
Select &tcField From (tcTable) ;
  where Recno() = tnRecNo ;
  into Table (lcTable)
Use
handle=Fopen(lcTable+".fpt")
handleout=Fcreate(tcOutFileName)
lnSize = Fseek(handle, 0, 2) && Seek to eof and get size
=Fseek(handle,599)           && Go to start of gen file
If ( lnSize - 599 ) % 2 = 0  && Might it be a duplicate ? Let's check
  lcFirst = Fread(handle, (lnSize - 599)/2) && Read first part to lcFirst
  lcSecond = Fread(handle, lnSize) && Read rest to lcSecond
&& lnSize is totlen
&& but fread() would stop at feof()
  =Fwrite(handleout, lcFirst, lnSize) && Again lnSize is bigger but
&& correct size would be written
  If lcFirst # lcSecond   && It was not a duplicate, so write lcSecond too
    =Fwrite(handleout, lcSecond, lnSize)
  Endif
Else
  =Fwrite(handleout, ;
    fread(handle,lnSize), ;
    lnSize)                 && Since now we have a size at hand.
&& So let's do readwrite in one pass
Endif
=Fclose(handle)
=Fclose(handleout)
Erase (lcTable+".*")
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