Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace in huge text file
Message
From
27/09/2005 12:39:08
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01053411
Message ID:
01053525
Views:
37
OK here is a quick throw:
Text to m.lcMyText noshow
0123AD0012123AD0012312AD0012341AD00AD001
EndText
lcTemp1 = Sys(2015)+'.txt'
lcTemp2 = Sys(2015)+'.txt'
StrToFile(m.lcMytext,m.lcTemp1)
hIn = Fopen(m.lcTemp1)
hOut = Fcreate(m.lcTemp2)
#define maxbuffer 5
l1 = ''
DO while !feof(m.hIn)
 l2 = Fread(m.hIn,maxbuffer)
 lcTran = Strtran(m.l1+m.l2,'AD00','BR77')
 Fwrite(m.hOut,lcTran , Len(m.l1))
 l1 = substr(lcTran,Len(m.l1)+1)
EndDo
Fwrite(m.hOut,m.l1,Len(m.l1))
Fclose(m.hIn)
Fclose(m.hOut)
Modify comm (m.lcTemp2)
Erase (m.lcTemp1)
Erase (m.lcTemp2)
Cetin


>After you do STRTRAN(FILETOSTR(), "< Something >", "< Someother >")) you can end up with "< Something >" presented in the result because of "< Someother >" combining with other parts of the text. When you do processing with FREAD() buffer by buffer, you'll have to keep some part of the previuous buffer to account for the possible split. It could cause replacement of the match created by previous STRTRAN.
>I'm not sure if this explanation is clearer than prevuous one. :)
>Maybe it would be simpler if you post modified code that can handle split so I can see if it has the problem I try describe above.
>
>
>>I don't understand.
>>Cetin
>>
>>>In general case it's not simple because the STRTRAN() could create match for the next one.
>>>
>>>>You're right. Not hard to handle luckily.
>>>>Cetin
>>>>
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform