Re: Clean up after you!
From: Ekkehard Domning (edo_at_domis.de)
Date: 08/29/04
- Next message: James B. Millard: "Re: Clean up after you!"
- Previous message: Rob Kennedy: "Re: Detecting a running application"
- In reply to: Geir Baardsen: "Clean up after you!"
- Next in thread: Geir Baardsen: "Re: Clean up after you!"
- Reply: Geir Baardsen: "Re: Clean up after you!"
- Reply: Geir Baardsen: "Re: Clean up after you!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 29 Aug 2004 22:24:36 +0200
Hello,
I am not sure that I have understood well, but the general answer is
- if You have not create an instance you have not to free the instance.
I assume that You have dropped the OpenDialog1 from Your example on Your form.
In this case the form has to free on the destruction of the form itself.
I am a bit confused about Your 'LoadGrid' procedure
- if the procedure need a Filename as a parameter, why did you make this
AssignFile call prior the procedure call. Where become the 'myfile' opened so
that You close it on the finally section?
The cleanest way is to pass the filename and leave the procedure open and
close
the file as needed by itself.
BTW try to avoid this AssignFile stuff and use the TFileStream Component
instead.
Another nice feature is the ReadFromFile function from a TStringList itself.
Assuming that You have Your data organized in a way that
<day>:<month>:<year>=<content>
represent data of one day, You can store all data in one stringlist and access
the data
with the Names, Value properties of the stringlist
e.g.
cells[x.y] :=
LoadedStringList.Values[IntToStr(Day)+':'+IntToStr(Month)+':'+IntToStr(Year)];
assuming the stringlist contains one string
'30:8:2004=Look at Newsgroup'
and the variables Day, Month and Year containing 30,8,2004 the cell will
filled with 'look at Newsgroup'
Best regards
Ekkehard
Geir Baardsen schrieb:
>
> 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;
>
> :-)
-- DomIS Integrated Services - Anette Domning M.A. Technische Beratung Vogelweide 19 - 31137 Hildesheim - Tel.: 05121-6971605 Mail: edo@domis.de Internet: http://www.domis.de
- Next message: James B. Millard: "Re: Clean up after you!"
- Previous message: Rob Kennedy: "Re: Detecting a running application"
- In reply to: Geir Baardsen: "Clean up after you!"
- Next in thread: Geir Baardsen: "Re: Clean up after you!"
- Reply: Geir Baardsen: "Re: Clean up after you!"
- Reply: Geir Baardsen: "Re: Clean up after you!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|