Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to delete first n lines from a logfile ??
Message
De
01/03/2006 11:37:49
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
MySQL
Divers
Thread ID:
01100361
Message ID:
01100435
Vues:
14
>
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform