>Dear Sir,
>
>I wrote following
>
>
>local lnI,csno,cuser,cdate,ctime,cstr, nbytes,cuser2,cdate2,ctime2,cstr2, nbytes2
>
>lcText = FILETOSTR("c:\myfile.txt")
>lnLines = ALINES(aTextLines,lcText,.T.)
>FOR lnI = 1 TO lnLines
>ENDFOR
>
>
>csno=lnI
>cuser=ALLTRIM(STR(RAND()*10))
>cdate=DTOC(DATE())
>ctime=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)
>
>
>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.