Autor Beitrag
MH1987
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 98



BeitragVerfasst: Do 28.06.07 15:39 
Hi,

kann mir bitte jemand zeigen wie ich aus einem dynamischen array einen bestimmten eintrag lösche?

Das array ist ein array of string und ein bestimmter name soll gelöscht werden!

Danke für Eure Hilfe!

Gruß,
Matthias
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 28.06.07 15:55 
Moin!

Warum keine TStringList statt array of String? :nixweiss:

Ansonsten: muss die Reihenfolge erhalten bleiben?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Do 28.06.07 15:59 
user profile iconNarses hat folgendes geschrieben:
Ansonsten: muss die Reihenfolge erhalten bleiben?

Wenn nein, reicht es das zu löschende Element mit dem Letzten zu vertauschen und dann das Array um eins zu verkürzen. ;)
MH1987 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 98



BeitragVerfasst: Do 28.06.07 16:12 
genau das hab ich versucht hat aber nícht geklappt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TMain.Button3Click(Sender: TObject);
var
  i,j: integer;
begin
  i:= 0;
  while Daten[i].ID <> loeschID do
    inc(i);
  j:= high(Daten);
  Daten[i]:= Daten[j];
  SetLength(Daten, j-1);
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 28.06.07 16:26 
Moin!

Nochmal: warum keine Stringliste? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
MH1987 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 98



BeitragVerfasst: Do 28.06.07 16:26 
ok, hab den Fehler selbst gefunden.... hab mich mit Lenth(Daten) und High(Daten) vertan...
MH1987 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 98



BeitragVerfasst: Do 28.06.07 16:28 
Zitat:

Nochmal: warum keine Stringliste? :gruebel:


weil ich die schon einigermaßen beherrsche und mir jetzt einmal das array anschaun wollte... Eben eigentlich nur aus übungszwecken

Gruß,
Matthias