Hi Luke,
I use System.Move() to copy the remainder of the array down over the empty
element:
Here, FEvents is the array and TXPEvent is the array element type. Note
that I manually keep track of the number of used elements in the array,
FCount, which is distinct from the max number of elements, High(FEvents) + 1.
procedure TXPEventNotifier.DeleteIdx(const idx: integer);
begin
if idx < FCount - 1 then
begin
// Move remainder of array down to cover 'empty' slot
System.Move(FEvents[idx + 1], FEvents[idx],
(FCount - idx - 1) * System.SizeOf(TXPEvent));
end;
System.Dec(FCount);
end;
Paul.
At 09:30 6/04/01 , you wrote:
>Simple one for ya:
> Delete(MyDynArray, MyIndex, 1);
>That doesn't work. "Incompatible types" where MyDynArray is.
>
>How do I remove an element from the middle of a dynamic array?
>
>Luke Pascoe.
----------------------------------------------------------
Paul Spain, Excellent Programming Company
mailto:[EMAIL PROTECTED]
----------------------------------------------------------
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"