Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.pascal.delphi.misc > #108

Re: TList

From "Stark" <franco.jommi@tin.it>
Newsgroups comp.lang.pascal.delphi.misc
References <4ec009ba$0$1390$4fafbaef@reader1.news.tin.it> <R9Uvq.37022$Ra6.4586@newsfe07.iad> <4ec14b21$0$1390$4fafbaef@reader1.news.tin.it> <4Cgwq.1992$ED3.1249@newsfe06.iad>
Subject Re: TList
Date 2011-11-15 12:11 +0100
Message-ID <4ec248b4$0$1387$4fafbaef@reader2.news.tin.it> (permalink)
Organization TIN.IT (http://www.tin.it)

Show all headers | View raw


> Delphi must be doing some extra type checking, that works in the older 
> versions.
>
>   You could always try this  FreeAndNill(frmList.Item[i] as TFramEdit);
>
>  But in any case, you have it working also, you do need to remove the 
> entry from the list because it'll be there next time containing a pointer 
> that isn't Nill and will point somewhere wildly.
>
>   I guess you could always mark that entry location as NIL but then
> you'd have to manage that other wise, you'll just keep increasing the size 
> of the Tlist with dead space in it.
>
>   Just think of Tlist as a managed array of 32 bit place holders.. which 
> is all it is. You can do the same thing if you simply had an array of 
> TframeEdit pointers somewhere, only the TList has the build in code to
> manage the entries in case you want to delete, insert, clear, add too etc.
>
>
>  Jamie
>
>
Thanks Jamie. The expression FreeAndNill(frmList.Item[i] as TFramEdit); 
doesn't work either. However, my proc works and looks as follows:

procedure TForm1.BtnClearAllRowsClick(Sender: TObject);
var
  i: integer;
begin
   for i := frmList.Count - 1 downto 0 do
   begin
      aFrame := TFrameEdit(frmList.Items[i]);
      FreeAndNil(aFrame);
      frmList.Delete(i);
   end;
end;
I think this does free all of the TFrameEdit objects previously created (see 
my first message).
Since the frmList held pointers to those objects, does deleting the TList 
entries get rid of the object references also ? 

Back to comp.lang.pascal.delphi.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

TList "Stark" <franco.jommi@tin.it> - 2011-11-13 19:17 +0100
  Re: TList Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.net> - 2011-11-13 13:41 -0500
    Re: TList "Stark" <franco.jommi@tin.it> - 2011-11-14 18:09 +0100
      Re: TList Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.net> - 2011-11-14 17:29 -0500
        Re: TList "Stark" <franco.jommi@tin.it> - 2011-11-15 12:11 +0100
        Re: TList "Maarten Wiltink" <maarten@kittensandcats.net> - 2011-11-17 00:07 +0100

csiph-web