Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace in huge text file
Message
From
27/09/2005 16:47:17
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01053411
Message ID:
01053643
Views:
15
>>Your code will miss some occurences that happens to be split between two sequential reads.

What if you create a DO WHILE loop to catch split values- something like
*---lcStringToReplace is the string we want to replace with something else

lcFirstChar=left(m.lcStringToReplace,1)
lnLen=len(m.lcStringToReplace)-1
...
lcString=fread(1,8092)

lcCheck=right(m.lcstring,m.lnLen)

do while m.lcFirstChar $ m.lcCheck and ! feof(1)
   lcCheck=substr(m.lcCheck,AT(m.lcFirstchar,m.lcCheck))
   if m.lcCheck == left(m.lcStringToReplace,len(m.lcCheck))
      lcstring=m.lcstring+FREAD(1,100)
      lcCheck=right(m.lcstring,m.lnLen)
    else 
      lcCheck=substr(m.lcCheck,2)
   endif
enddo
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Reply
Map
View

Click here to load this message in the networking platform