Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to extract General Field's Data into File ?
Message
From
20/08/1999 05:14:08
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/08/1999 21:16:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00255653
Message ID:
00255738
Views:
10
>Hi all Falks~
>I have a question about General Field.
>In my Table, there is a one General Field and it contains bmp files.
>But now I must extract it's data ( bmp files ) into files.
>
>How can I do for it ?
>Have you any idea ?
>
>Thanks.
>Dongbum Lee

Wish it could be that easy as Erik thought. But you cannot do the first line for general fields.
I use this function :
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+".bmp")
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+".*")
599 and data might be doubled aren't my self ideas. I got them from MS KB :)
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
Reply
Map
View

Click here to load this message in the networking platform