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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to a text file 2

Status
Not open for further replies.

Jonah86

Programmer
Dec 11, 2003
152
US
Is there a way to write a new line to an existing text file from Delphi? The file would be saved on a network drive and users would hit a button to report a problem with a certain aspect of the program, and it would just add a line of text to the text file based on some criteria.

I'm not sure if this is something that can be done or not. I tried searching, but didn't get any results I could use.

Thanks.
 
Use TextFile.

For example, if you want to add the line 'Hello World' to the file c:\log.txt in the Button1 OnClick handler your code would look something like:-
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  f: TextFile;
begin
  AssignFile ( f, 'c:\log.txt' );
  Append ( f );
  WriteLn ( f, 'Hello World' );
  CloseFile ( f );
end;

Andrew
Hampshire, UK
 
That's so perfect I could kiss you!

kidding, but thanks:)
 
Are you sure Andrew!!! ;-)

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top