Don,
If those characters are always the last charaters of the file, then following code will be much faster.
LPARAMETER pcFileName
IF NOT FILE(pcFileName)
WAIT' ERROR: FILE '+pcFileName+' DOES NOT EXIST' WINDOW
RETURN .F.
ENDIF
LOCAL nHandle, nFileSize, cData, cNewSize, nIOError, lRet
nHandle = FOPEN(pcFileName,2)
IF nHandle < 0
WAIT' ERROR: CANNOT OPRN FILE '+pcFileName WINDOW
RETURN .F.
ENDIF
nNewSize = FSEEK(nHandle,-1,2)
cData = FREAD(nHandle,1)
lRet = .T.
IF ASC(cData) = 26 OR ASC(cData) = 141
IF FCHSIZE(nHandle, nNewSize) < 0
WAIT 'ERROR WRITING TO FILE: '+ALLTRIM(STR(FERROR())) WINDOW
lRet = .F.
ENDIF
ENDIF
=FCLOSE(nHandle)
RETURN lRet
You certanly would want to replace or eleminate WAIT WINDOW in the above code. :)
>Hi Hilmar
>
>I think I have it resolved. By hand, I have gone through the text files and identified the ASCII characters, principally 26 and 141. Instead of having a FOR..ENDFOR loop with a STRTRAN in between, I just added two lines:
> lcCleanStr = CHRTRAN(lcCleanStr,CHR(26),'')
> lcCleanStr = CHRTRAN(lcCleanStr,CHR(141),'')
>
>Also, this is an operation that runs for a considerable period of time. On customer locations with really large numbers of text files, it could take hours. The table involved is never closed until the operation is complete. If a table remains open, I read somewhere that Fox only actually writes to disk at certain intervals (something like once every five minutes). I have been interrupting the program after a few hundred records. I may have interrupted the operation before an actual physical write to disk, thereby getting the memo from the previous overwrite. In a Belt and Suspenders move, I also added a FLUSH every 1000 records.
>
>This seems to work fine. Thank you for your assistance.
>
>Don Lowrey
--sb--