Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to delete first n lines from a logfile ??
Message
From
01/03/2006 11:37:49
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
MySQL
Miscellaneous
Thread ID:
01100361
Message ID:
01100435
Views:
13
>
>lcstring=FILETOSTR(filename)
>if OCCURS(CHR(13)+CHR(10),lcstring)>5000
>     =strtofile(substr(lcstring, at(CHR(13)+CHR(10),lcstring,1000)+2,filename)
>endif
>
You beat me to this one... but then, it's not perfect - we are relying on the EOL marker being CRLF, but the file could have been edited with something that leaves only a CR (OK, nitpicking, I know). So just to show that the usual number of ways to do something in Fox is not always three, it can be much more:
lcString=filetorstr(filename)
set memowith to 200 && or as needed
n=memlines(lcString)
if n>5000
   cl1001=mline(lcString,1001)   && the first line to keep
   strtofile("Truncated at "+transform(datetime())+;
      substr(lcString, at(cl1001, lcString)+len(cl1001)), filename)
endif

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform