Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to delete first n lines from a logfile ??
Message
 
 
À
01/03/2006 08:59:13
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Allemagne
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:
01100372
Vues:
11
You have to write to new file and than delete old one and rename new one, if necessary. Her's a pseudo code
lhErrorLog = FOPEN(<Existing Log file>)
lhNewErrorLog = FCREATE(<New log File>,12)
lnCounter = 0
DO WHILE NOT FEOF()
  lcBuffer = FRGET(lhErrorLog, 256)
  lnCounter = lnCounter + 1 
  IF lnCounter > 1000
    FFPUT(lhNewErrorLog, lcBuffer)
  ENDIF
ENDDO
...
>I create logfile entrys with a routine like this
>	lsErrorLog = "c:\mylog.Log"
>	lhErrorLog = FOPEN(lsErrorLog, 12)
>
>	* create if not there
>	IF lhErrorLog < 0
>	  lhErrorLog = FCREATE(lsErrorLog)
>	ENDIF
>
>	
>	  = FSEEK(lhErrorLog, 0, 2)
>	  = FPUTS(lhErrorLog, "Datum   : " + DTOC(DATE())    + " " + TIME())
>	  = FPUTS(lhErrorLog, "Message : " + STR(tnError, 5) + " " + tsMessage)
>	  = FPUTS(lhErrorLog, "Line    : " + STR(tnLine,  5) + " " + tsLine)
>	  = FPUTS(lhErrorLog, "Rechner : " + sys(0))
>	  = FPUTS(lhErrorLog, "*******************************************************" )
>	  = FPUTS(lhErrorLog, "")
>
>	* close
>	IF lhErrorLog >=0
>	  = FCLOSE(lhErrorLog)
>	ENDIF
>Now i want to delete the first 1000 lines from mylog.log when mylog.log has more then
>5000 lines.
>
>Can someone show me how to code this ??
>
>Best regards
>Albert
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform