Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting data FROM a general field
Message
From
18/11/1999 02:26:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00291910
Message ID:
00292303
Views:
20
>I have a column in a SQL server table that I referance via VFP
>5.0 remote view. In the table there is a column with the type
>"image" this column is seen as a "general" in VFP. I need to get
>the data in that column and write it to a file with the users
>choice of name. How can this be done? I initaly thought there
>might be a "copy from general" that worked like "copy from memo"
>no such luck.
>
>HELP !!!
>
>Thanks in advance
>
>Alan Sheffield


Alan,
You can try this routine after changing slightly (automatically adds bmp extension) :
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+".*")
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