Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find and Replace in huge text file
Message
De
27/09/2005 12:39:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01053411
Message ID:
01053525
Vues:
39
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform