function SaveBMP 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+".*")Since this code doesn't do extra check for contents and extension, it's assumed that you are responsible for giving correct data for a BMP. MS doesn't say it and I didn't tested but IMHO this routine with some modification could be used as "copy general" for any general data type (I wonder why FP folks didn't do it when they have all the data of structure in first place and it wouldn't be much different from "copy memo"). For batch processing I would add another field as FileType, create a bmp directory (say mybmps) and :
scan for FileType = "BMP" =SaveBMP(alias(), "mygenfield", recno(), "myBMPs\"+ltrim(str(recno())) ) endscanCetin