I did some modification to Cetin Greg code, here it is:-
#DEFINE MAXBUFFER 65530
lhIn = FOPEN(lcFileIn)
lhOut = FCREATE(lcFileOut)
DO WHILE NOT FEOF(m.lhIn )
lcBuffer = FREAD(m.lhIn, MAXBUFFER)
lnfindlen = LEN(cFind)
FOR lncounter = lnfindlen TO 1 STEP -1
IF RIGHT(lcBuffer,lncounter) == SUBSTR(cFind, 1, lncounter)
FSEEK(m.lhIn, -(lncounter), 1)
lcBuffer = LEFT(lcBuffer,LEN(lcBuffer) - lncounter)
ENDIF
ENDFOR
lcBufferOut = STRTRAN(lcBuffer,cFind,cReplace)
FWRITE(m.lhOut, lcBufferOut)
ENDDO
FCLOSE(m.lhIn)
FCLOSE(m.lhOut)
>>>>Try this (modified from Cetin code) for testing if the replaced string is being split during FREADs:
>>>>
>>>>>
>>>>#DEFINE MAXBUFFER 65536
>>>>lhIn = FOPEN(lcFileIn)
>>>>lhOut = FCREATE(lcFileOut)
>>>>DO WHILE NOT FEOF(m.lhIn )
>>>> lcBuffer = FREAD(m.lhIn, MAXBUFFER)
>>>> DO CASE
>>>> CASE RIGHT(lcBuffer,3) = 'AD0'
>>>> FSEEK(m.lhIn, -3, 1)
>>>> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-3)
>>>> CASE RIGHT(lcBuffer,2) = 'AD'
>>>> FSEEK(m.lhIn, -2, 1)
>>>> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-2)
>>>> CASE RIGHT(lcBuffer,1) = 'A'
>>>> FSEEK(m.lhIn, -1, 1)
>>>> lcBuffer = LEFT(lcBuffer,LEN(lcBuffer)-1)
>>>> ENDCASE
>>>> FWRITE(m.lhOut,STRTRAN(lcBuffer,'AD00','BR77'),MAXBUFFER)
>>>>ENDDO
>>>>FCLOSE(m.lhIn)
>>>>FCLOSE(m.lhOut)
>>>
>>>this is incorrect.
>>>you cannot mix a right find/replace with a left find/replace
>>
>>I am not sure what you mean cannot mix a right find/replace with a left find replace. The above code looks at >the last 3 bytes to determine if they can possibly be part of the search string. If there is a possiblity, >then >the position in the file is moved by the number of possible matching bytes (FSEEK) and the possible >matching >bytes is removed from the read buffer before any string replacement is made.
>>
>>This is the issue.
>>example:
>>