Re: Clean up after you!
From: Tom de Neef (tdeneef_at_qolor.nl)
Date: 08/29/04
- Next message: Duncan Murdoch: "Re: Clean up after you!"
- Previous message: Maarten Wiltink: "Re: Clean up after you!"
- In reply to: Geir Baardsen: "Clean up after you!"
- Next in thread: James B. Millard: "Re: Clean up after you!"
- Reply: James B. Millard: "Re: Clean up after you!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 29 Aug 2004 20:24:36 +0200
"Geir Baardsen" <geir_baardsen@hotmail.com> schreef in bericht
news:35f9d8b7.0408290803.4b4de284@posting.google.com...
> Hi!
> Can anybody tell me if I'm doing the following in a wrong way?
>
> What I do is have a textfile loaded into a stringgrid by the help
> of an OpenDialog
> (it works fine, but am I cleaning up after me?,
> Do I need to free the OpenDialog1?):
>
> procedure TfrmTimeList.btnOpenFileClick(Sender: TObject);
> var
> MyFile : TextFile;
> begin
> try
> if OpenDialog1.Execute then
> begin
> AssignFile(MyFile, OpenDialog1.FileName);
> try
> LoadGrid(grTimeList,OpenDialog1.FileName);
> with grTimeList do
> begin
> FixedColor := clBtnFace;
> EditorMode := false;
> ColCount := 5;
> RowCount := 32;
> ColWidths[1] := 200;
> ColWidths[2] := 50;
> ColWidths[3] := 200;
> ColWidths[4] := 50;
> end;
> except
> on E:EInOutError do
> ShowMessage(E.Message);
> end;
> end;
> finally
> CloseFile(MyFile);
> end;
> end;
>
> :-)
You don't need to free the OpenDialog1 since you did not create it. (I.e. it
was created elsewhere and will be destroyed elsewhere as well.) See
Maarten's feedback.
But I wondered why you assign(MyFile) and later CloseFile(MyFile). What
happens when you remove those statements and the definition of MyFile as
well. It doesn't seem to contribute anything.
Tom
- Next message: Duncan Murdoch: "Re: Clean up after you!"
- Previous message: Maarten Wiltink: "Re: Clean up after you!"
- In reply to: Geir Baardsen: "Clean up after you!"
- Next in thread: James B. Millard: "Re: Clean up after you!"
- Reply: James B. Millard: "Re: Clean up after you!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|