Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General Field Export? 1

Status
Not open for further replies.

jotita

Programmer
Aug 19, 2002
19
AR
Hello!
I have a DBF with a general field with a dd.BMP on it.
I need to save to a file xx.bmp, extract from the general field in Visual Foxpro 6.
I have inserted it with appe general, but for export it?
 
jotita,

Code:
LOCAL lcFileString
SELECT "MyTable"
COPY TO tmpTable FIELDS YourGeneralField NEXT 1
lcFileString=FILETOSTR("tmpTable.fpt")
ERASE "tmpTable.fpt"
ERASE "tmpTable.dbf"
lcFileString = RIGHT(lcFileString,LEN(lcFileString) - 599)
=STRTOFILE(lcFileString, "MyExport.bmp")


boyd.gif

 
Craig, I am curious is VFP always add 600 bytes, no metter what files you store in General field or this is only for BMPs?

Never used General fields, so I didn't pay attenetion to them.

T I A

Borislav Borissov
 
I think it's to do with the class ID or the associated program at the time the file is stored.

Regards

Griff
Keep [Smile]ing
 
Hmm, Doug Henning did it another way and wrote a reportlistener for converting general to blob fields. But that also just applies to images:


I made a simple test and put a mp3 file to a general field with APPEND GENERAL, extracting it again with craigs code. The final file can be played with winamp or windows media player, but it is about 8kb larger than the original file, so there seems to be a portion of unneeded bytes. I don't have checked, if that is always the same length, but I don't think so.

Bye, Olaf.
 
Hmm, not even close. If comparing lcFilestring I saved to "myexport.mp3" to filetostr(<the original mp3 file>) it gives .f., not only with == but also with =, so the general field fpt header for an mp3 object seems to be larger than for a bmp. The players are clever enough to find the audio frames.

In this case I should have removed 105 bytes more from the left side of the fpt file. So the offset is dependant of the file type.

Bye, Olaf.
 
A great many file formats have certain data at the very beginning of them can be relied on... so a person could write code that searched in the string for this information and truncated the data that appears before it. But, as OlafDoschke has already elluded to that would be dependent on the file type and the ability to reliably figure the correct offset based on searched for data.

boyd.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top