I know this has been answered but:
I would like to add one thing, if you are going to use one command button for more then one function
I would recomend that you change the command caption accordingly per the new task of the
buttons function etc.
procedure TForm1.Button1Click(Sender: TObject);
begin
if edit1.Text <> '' then
begin
edit1.text := '';
button1.Caption := 'Write';
end
else
begin
edit1.text := 'You Text Here';
button1.caption := 'Erase';
end;
end;
In this way you will allow the user to know whats going on, making your app user
friendly, so assuming your app starts out with empty text in edit1, make your caption
at design time for button1 to read Write, so when you run and click on button1 two things
will happen, The caption of the button will change to erase, and edit1 will now have the text
you want, so next time you click the button, edit1 value will clear and caption for button1 will change to
write again. Hope this helps