Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Software Log File
Message
De
27/04/2007 08:35:21
 
 
À
27/04/2007 08:24:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01220348
Message ID:
01220391
Vues:
22
>Dear Sir,
>
>I wrote following
>
>
>local lnI,csno,cuser,cdate,ctime,cstr, nbytes,cuser2,cdate2,ctime2,cstr2, nbytes2
>&& To findout last serial number
>lcText = FILETOSTR("c:\myfile.txt")
>lnLines = ALINES(aTextLines,lcText,.T.)	
>FOR lnI = 1 TO lnLines
>ENDFOR
>
>&& this procedure is starup prg
>csno=lnI  					&& last serial number+1
>cuser=ALLTRIM(STR(RAND()*10))&& user name
>cdate=DTOC(DATE()) 			&& date
>ctime=TIME() 				&& time
>cstr=ALLTRIM(STR(csno))+CHR(9)+ALLTRIM('user')+cuser+CHR(9)+cdate+CHR(9)+ctime
>nbytes = strtofile(cstr+ chr(13) + chr(10),+"c:\myfile.txt",1)
>
>&& this procedure runs when exe stopped
>cuser2=ALLTRIM(STR(RAND()*10))
>cdate2=DTOC(DATE()) 			
>ctime2=TIME() 				
>cstr2=ALLTRIM('user')+cuser2+CHR(9)+cdate2+CHR(9)+ctime2
>nbytes2 = strtofile(cstr2, "c:\myfile.txt",1)
>
>I want to add cstr2 at the end to then last line instead of new line
>How to findout last line of myfile.txt and add specific data at the end of last line?
>
>Please help

Well I just gave you help and you ignored everything I said. Why not use the DATETIME() function which returns the date & time in one command, and in the format you wanted your message?

Now, you can do it your way if you wish. But if you follow my code then:

= FSEEK( lnFileHdl, 1, 2)

will take you to the end of the text file

You can use FWRITE() to write a string to the file, instead of FPUTS(), because FPUTS() adds a CR/LF to the end of the writing, whereas FWRITE() does not.

Also, there's no need to write to the file in two separate lumps. You can store the date/time on and write both values just at the end. Hence, only one STRTOFILE() call.
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform