Board index » delphi » Newbie: Getting SaveDialog to save a file

Newbie: Getting SaveDialog to save a file

I am a real newbie to Delphi. I know DOS Pascal but this is confusing to
me.
I am doing a word processor for a senior project. I am using a mainmenu
component and when the user clicks Save As the code below should be
executed. I've been looking for example code in Delphi's Online
help--couldn't find it. I just want to save a file after the user clicks
on OK in the SaveDialog window. What do I dooooooo?????
By the way, TTextViewer is of class(TForm).

Song
sle...@halcyon.com

procedure TTextViewer.SaveAs1Click(Sender: TObject);
begin
 If SaveDialog1.Execute Then
  begin
  end;
end;

Thanks in advance.

Song - sle...@halcyon.com

 

Re:Newbie: Getting SaveDialog to save a file


Quote
Song <sle...@halcyon.com> wrote:
>I am a real newbie to Delphi. I know DOS Pascal but this is confusing to
>me.
>I am doing a word processor for a senior project. I am using a mainmenu
>component and when the user clicks Save As the code below should be
>executed. I've been looking for example code in Delphi's Online
>help--couldn't find it. I just want to save a file after the user clicks
>on OK in the SaveDialog window. What do I dooooooo?????
>By the way, TTextViewer is of class(TForm).
>Song
>sle...@halcyon.com
>procedure TTextViewer.SaveAs1Click(Sender: TObject);
>begin
> If SaveDialog1.Execute Then
>  begin
>  end;
>end;
>Thanks in advance.
>Song - sle...@halcyon.com

If you haven't discovered the demos that come with Delphi then you've
been missing a good source of information. Look in the delphi\demos
directory for all sorts of useful code demos. Look in
delphi\demos\textdemo\main.pas for a demo that " { shows how to use
the TOpenDialog, TSaveDialog, TFindDialog and TReplaceDialog
components along with the LoadFromFile and SaveToFile methods of a
TStringList (in this case the string list in Memo1). }

HTH
--
Michael Purcell
purc...@atlanta.com
Atlanta, Georgia USA

Re:Newbie: Getting SaveDialog to save a file


You didn't mention what type of control was holding the text,
but...assuming that it's a TMemo called Memo1,

procedure TTextViewer.SaveAs1Click(Sender: TObject);
begin
    if SaveDialog1.Execute then
        Memo1.SaveToFile(SaveDialog1.FileName);
end;

...should do what you want.

Ken White
qpwpla...@aol.com

Other Threads