Board index » delphi » TList.Delete & Remove misrepresented?

TList.Delete & Remove misrepresented?

According to the online documentation for TList, if you call
Delete( itemIndex ) or Remove( item ), the item is removed from
the list AND  NIL appears in its place.  This allows the indices
for the other list items to remain constant; if you want to remove
those NILs, you call Pack, or so the documentation says.

But when I have a list and use either Remove or Delete to get rid of
the first item in the list, no NIL pointer appears; instead the
other items all are moved up in the list.

When I delete one item in the list, I DO NOT want the indices of the
others to change.

How can I get Delphi to behave in accordance with its documentation?

Thanks for any input,
Anna Haynes

p.s.  I'm using the 16bit version 1 Delphi ( I think; the
About dialog box yields a simply lovely picture, but no
information. )

--------
Anna Haynes      
<a...@empress.gvg.tek.com>  
I do not speak for Tektronix.

 

Re:TList.Delete & Remove misrepresented?


In article <4oap98$...@gv-gate.gvg.tek.com> a...@empress.gvg.tek.com (Anna K. Haynes) writes:

Quote
>From: a...@empress.gvg.tek.com (Anna K. Haynes)
>Subject: TList.Delete & Remove misrepresented?
>Date: 26 May 1996 23:25:28 GMT
>According to the online documentation for TList, if you call
>Delete( itemIndex ) or Remove( item ), the item is removed from
>the list AND  NIL appears in its place.  This allows the indices
>for the other list items to remain constant; if you want to remove
>those NILs, you call Pack, or so the documentation says.
>But when I have a list and use either Remove or Delete to get rid of
>the first item in the list, no NIL pointer appears; instead the
>other items all are moved up in the list.
>When I delete one item in the list, I DO NOT want the indices of the
>others to change.
>How can I get Delphi to behave in accordance with its documentation?

I think you will have a descend an object from tlist, which overrides &
implements the delete the way you want it.

HTH

Boris Ingram, Cyborg Software
boris...@iafrica.com
Compuserve : 100076, 3616
http://www.pcb.co.za/users/borising/cyborg.htm

Re:TList.Delete & Remove misrepresented?


On Mon, 27 May 1996 08:44:59, boris...@iafrica.com (Boris Ingram)
wrote:

Quote
>In article <4oap98$...@gv-gate.gvg.tek.com> a...@empress.gvg.tek.com (Anna K. Haynes) writes:
>>According to the online documentation for TList, if you call
>>Delete( itemIndex ) or Remove( item ), the item is removed from
>>the list AND  NIL appears in its place.  This allows the indices
>>for the other list items to remain constant; if you want to remove
>>those NILs, you call Pack, or so the documentation says.
...
>>How can I get Delphi to behave in accordance with its documentation?

Just set the item to nil.
  Delete is: List[Index] := nil
  Remove is: List[IndexOf(Item)] := nil

--
Ray Lischner                              li...@tempest-sw.com
Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

Re:TList.Delete & Remove misrepresented?


Anna K. Haynes <a...@empress.gvg.tek.com> wrote:

Quote

> How can I get Delphi to behave in accordance with its documentation?

how about changing the documentation :_)

--
Michael.Jus...@ac.{*word*104}city.de

Other Threads