Home > Back-end >  Delphi array delete records
Delphi array delete records

Time:10-08

In the process of program is running, will continue to give such a array insert records, as the increasing of data, memory also reached 100%, so the
Wonder, how can delete part of the record? Masters to help you, online, etc., very anxious!

Type
TprocessReceive=record
FSTR: string [30];
Fld_flagyzm: integer;
end;

ArrayprocessReceive: an Array of TprocessReceive;

CodePudding user response:

There is no answer, please top yourself!

CodePudding user response:

If you are new then dispose off

CodePudding user response:

But I this is not ah!

CodePudding user response:

Dynamic array can use Move function
SetLength again

CodePudding user response:

This may use TList management convenient point

CodePudding user response:

 procedure TForm3. Add; 
The begin
Inc (Count);
SetLength (ArrayprocessReceive, Count);

FSTR ArrayprocessReceive [Count - 1]='s' + IntToStr (Count);
Fld_flagyzm ArrayprocessReceive [Count - 1]=Count;
end;
Procedure TForm3. Del (const index: Integer);
The begin
If (Index & lt; 0) or (Index & gt;=Count) then
Raise the Exception. The Create (' Argument out of range);

Dec (Count);
If the index & lt;> The Count then
The begin
ArrayprocessReceive Move (ArrayprocessReceive [index + 1], [index], (the Count - index) * SizeOf (TprocessReceive));
SetLength (ArrayprocessReceive, Count);
end;
end;

Procedure TForm3. Btn1Click (Sender: TObject);
The begin
The Add;
end;

Procedure TForm3. Btn2Click (Sender: TObject);
The begin
Del (0);
end;

Procedure TForm3. FormCreate (Sender: TObject);
The begin
Count:=0;
end;

CodePudding user response:

This structure into a class, and then use TObjectList To manage,

 

USES the
Generics. Collections;


Type
TProcessReceive=class (TObject)
Private
FstrMsg: string;
Ffld_flagyzm: Integer;
Procedure Setfld_flagyzm (const Value: Integer);
Procedure SetstrMsg (const Value: string);

Protected

Public
The constructor Create;
The destructor Destroy; Override.
Published
The property strMsg: string read FstrMsg write SetstrMsg;
The property fld_flagyzm: Integer read Ffld_flagyzm write Setfld_flagyzm;
end;


Var
ObjList: TObjectList;//use generics to management,

CodePudding user response:

TObjectList Support now.

CodePudding user response:

Memory table can also ah,
  • Related