Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract files from general field
Message
From
13/10/2005 13:31:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/10/2005 13:13:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01058768
Message ID:
01058778
Views:
13
>Hi all !
>
>I have a table with 500 records. This table store into a general field bitmap files (embeded). I want to extract programatic all files to disk. It's possible ?
>
>Thanks in advance.

Take a backup and try this old routine (if all is BMP):
-Adjust table and gen field name and create mybmps subfolder.
Clear All
Use myTable
Scan
  =savebmps(Alias(), "genfieldName", Recno(), "mybmps\"+Ltrim(Str(Recno())))
Endscan

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 except .BMP extension (no check)
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform