Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find and Replace in huge text file
Message
From
28/09/2005 05:03:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/09/2005 04:54:53
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01053411
Message ID:
01053793
Views:
25
>how appetizer :)
>
>TEXT to m.lcMyText noshow
>0AD0AD0012123AD0012312AD0012341AD00AD0010123
>12AD0012123AD0012312AD0012341AD00AD0010123AD0012123AD0012312AD0012341AD00AD001
>ENDTEXT
>lcTemp1 = Sys(2015)+'.txt'
>lcTemp2 = Sys(2015)+'.txt'
>
>************************** look here ***************************
>Strtofile(m.lcMytext+'A',m.lcTemp1)
>
>*!*	lcTemp1 = 'bigfile.txt' && 138Mb
>*!*	lcTemp1 = 'bigfile.tx2' && 26Mb
>*!*	lcTemp2 = 'bigfile.ou2'
>
>#Define MAXBUFFER 5
>
>lhIn = Fopen(m.lcTemp1)
>lhOut = Fcreate(m.lcTemp2)
>Set Step On
>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)
>Modify Comm (m.lcTemp2)
>Erase (m.lcTemp1)
>Erase (m.lcTemp2)
>
Come on Fabio. You introduced a simple bug that you could easily fix with if..endif I'm sure. That still doesn't deny the fact that this code works. Stars from me to Greg.
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
Next
Reply
Map
View

Click here to load this message in the networking platform