Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting the last line of a text file

Status
Not open for further replies.

Matta25

Technical User
Jan 6, 2004
82
0
0
US
Hello,
I'm writing data to a text file using hte Fput Append Text command. When the last string is written the file has a blank line at the end. I there an easy way to delete this blank line?
thanks
 
Are you adding any carriage returns or linefeeds to the string before you write it? If so, you will not want to do so since using the TEXT flag with fputs automatically adds carriage returns and linefeeds when writing to a file, so that may explain the extra blank line.


 
It just using a findfirst command to get a filename and using the fputs to write the filename to the file.
 
OK, the best way to work around this is to not open the text file with the TEXT flag to keep the fputs command from automatically writing a carriage return and linefeed after each string. This is what is causing the blank line at the end. What you will need to instead is add:

fwrite 0 "`r`n" 2

prior to each fputs command you have now so that a carriage return and linefeed are added manually so the new string is on its own line.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top