Examples Delphi

procedure TForm1.SaveButtonClick(Sender: TObject);
{re-use this code elsewhere}
begin
if (SaveDialog.Filename = '') then
begin
with SaveDialog do
begin
if Execute then
begin
MainMemo.Lines.SaveToFile(Filename);
Caption := 'Richards Text Editor - ' +
ExtractFilename(Filename);
end; {if}
end; {with}
end {if}
else
begin
MainMemo.Lines.SaveToFile(SaveDialog.Filename);
end; {else}
end;
procedure TForm1.SaveAsButtonClick(Sender: TObject);
begin
with SaveDialog do
begin
if Execute then
begin
MainMemo.Lines.SaveToFile(Filename);
Caption := 'Richards Text Editor - ' +
ExtractFilename(Filename);
end;
end;
end;