*Example 1 *Table is bridges.dbf *general field is bridges.icon *it is the actual icon file in the general field, not a link *For testing purposes, I opened the table *and position the record pointer to a record with an icon in *the icon field *I passed "icon" as the field name to this program. ***************************************************************************** LPARAMETERS tcGenFldName LOCAL lnInHandle LOCAL lnOutHandle LOCAL lnFileLen LOCAL lcTmpFile LOCAL lcBmpFile LOCAL lcString LOCAL loResult LOCAL lcOldComp lcTmpFile = ADDBS(SYS(2023)) + SYS(2015) lcBmpFile = "c:\accuwin\sc\vendor\proaccu.ico" COPY TO (lcTmpFile) FIELDS (tcGenFldName) NEXT 1 lnInHandle = FOPEN(lcTmpFile + '.FPT') lnOutHandle = FCREATE(lcBmpFile) IF lnInHandle >0 AND lnOutHandle > 0 lnFileLen = FSEEK(lnInHandle, 0, 2) = FSEEK(lnInHandle, 0) lcString = FREAD(lnInHandle, lnFileLen) lcString = RIGHT(lcString, LEN(lcString) - 599) =FWRITE(lnOutHandle, lcString) ELSE lcBmpFile = '' ENDIF =FCLOSE(lnInHandle) =FCLOSE(lnOutHandle) IF FILE(lcTmpFile + '.FPT') DELETE FILE (lcTmpFile + '.*') ENDIF RETURN lcBmpFile **************************************************************************
USE bridges GO top COPY TO temp FIELDS icon NEXT 1 *** and Create a file handle for the output file "Test.Bmp" handlein=FOPEN("temp.fpt") handleout=FCREATE("c:\accuwin\sc\vendor\proaccu.ico") *** To determine the length of the Input file "Temp.fpt" gnEnd = FSEEK(handlein, 0, 2) gnTop = FSEEK(handlein, 0) *** Store the whole file into a string "str1" str1 = FREAD(handlein, gnEnd) *** Offset 599 bytes from Str1 and save it to "str2" str2=RIGHT(str1,LEN(str1)-599) *** Write "Str2" into the BMP file "Test.BMP" n=FWRITE(handleout,str2) *** Close both opened files =FCLOSE(handlein) =FCLOSE(handleout) FLUSH
USE bridges GO top lctemp=sys(2015) COPY GENERAL to (lctemp) next 1 lcOUtFileName="c:\accuwin\sc\vendor\proaccu.ico" Hin = fopen(lcTemp+".fpt") hout=fcreate(lcOutFileName) lnSize=fseek(hin,0,2) fseek(hin,0x204,0) && Move file pointer to offset 0x204 where file size is stored lnSize = 0 for ix=4 to 1 step -1 && Get file size lnSize=lnSize+asc(fread(hin,1))*256^(ix-1) endfor fwrite(hout,fread(hin,lnSize),lnSize) =fclose(hin) and fclose(hout) flush