Re: Just a simple question on .Free
From: Bruce Roberts (ber_at_bounceitattcanada.xnet)
Date: 12/01/04
- Next message: Justus J.: "Re: application wide class"
- Previous message: Bruce Roberts: "Re: Break a loop with a button"
- In reply to: Christakis John: "Re: Just a simple question on .Free"
- Next in thread: Christakis John: "Re: Just a simple question on .Free"
- Reply: Christakis John: "Re: Just a simple question on .Free"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 1 Dec 2004 12:50:52 -0500
"Christakis John" <dontemail@me.please.ok> wrote in message
news:z7crd.54365$K7.19510@news-server.bigpond.net.au...
> One last thing - is there any way to get to the with'd object. eg:
>
> say I have this function
>
> function mycount(stl : TStringList) : integer;
> begin
> Result:=stl.Count;
> end;
>
> and then I use a stringlist in a with like this:
>
> With TStringList.Create do
I presume you forgot a Begin here.
> Strings.Add('hello');
> Strings.Add('world');
> ----
> Free;
> end;
>
> is there a way I can insert myCount() at ---- and have it use the
stringlist
> that is active there? Does that make sense? I tried 'Self' but that
didn't
> work.
With is not a good construct to use in Delphi. A google search of this ng
will turn up multiple threads as to why. I'd suggest a coding more like
var myStringList : tStringList;
. . .
myStringList : tStringList.Create;
try
myStringList.Add ('hello');
myStringList.Add ('world');
. . .
ShowMessage ('Count is ' + IntToStr (myCount (myStringList)));
. . .
finally
myStringList.Free;
end;
. . .
- Next message: Justus J.: "Re: application wide class"
- Previous message: Bruce Roberts: "Re: Break a loop with a button"
- In reply to: Christakis John: "Re: Just a simple question on .Free"
- Next in thread: Christakis John: "Re: Just a simple question on .Free"
- Reply: Christakis John: "Re: Just a simple question on .Free"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|