*********************************************************** ** ExtractBMP ** Extracts a BMP file stored in a General field to a file. ** Parameters: ** cGenField - Name of general field to export ** cFileName - Name of file to store BMP ** Note - While this works most of the time it is not 100%. *********************************************************** FUNCTION ExtractBMP LPARAMETERS cGenField, cFileName LOCAL cTempTable, cTempMemo, cFile, nAt cFileName = DEFAULTEXT(cFileName,"bmp") IF TYPE(cGenField) <> "G" MESSAGEBOX(cGenField+" is not a general field") RETURN .F. ENDIF ** Temporary work area cTempTable = ADDBS(SYS(2023))+SYS(2015)+".tmp" cTempMemo = FORCEEXT(cTempTable, "fpt") COPY TO (cTempTable) FIELDS (cGenField) NEXT 1 ** Convert memo file to string cFile = FILETOSTR(cTempMemo) ** Delete temp work area DELETE FILE (cTempTable) DELETE FILE (cTempMemo) ** Locate BMP start byte nAt = AT("BM",cFile) IF nAt > 0 ** Truncate string cFile = SUBSTR(cFile, nAt) STRTOFILE(cFile, cFileName) ElSE MESSAGEBOX("Could not locate BMP file in field") RETURN .F. ENDIF RETURN .T.