Autor Beitrag
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Fr 10.03.06 00:10 
Hmm... hab mal wieder n brett vorm kopf:
eigentlich sollte diese Prozedur ein Element aus einem Array löschen,
indem alle nachfolgenden elemente nach oben verschoben werden und dann das array gekürzt wird. In der Zeile mit SetLength meckert mir der Compiler aber 'inkompatible typen'
Ich sehr aber grad nicht warum....

ach ja: TQuest ist bekannt und es werden nur arrays erwartet die bei 0 beginnen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure DeletePosition(var inputarray : array of TQuest; position : integer);
  var i : integer;
  begin
    if position < high(inputarray) then
      for i:=position to high(inputarray)-1 do
        inputarray[i]:=inputarray[i+1];

    SetLength(inputarray, high(inputarray));  //Mecker
  end;



Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am Fr 10.03.2006 um 00:39

_________________
Delphi: XE - OS: Windows 7 Professional x64
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 10.03.06 00:44 
Um ein Array korrekt als Parameter übergeben zu können, musst Du einen eigenen Typen definieren:
ausblenden Delphi-Quelltext
1:
TQuestArray = Array of TQuest;					


Die Prozedur änderst Du dann so:
ausblenden Delphi-Quelltext
1:
procedure DeletePosition(var inputarray : TQuestArray; position : integer);					

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Fr 10.03.06 00:51 
Stand mal genau vor dem gleichen Problem. Wenn Christians Lösung funktioniert dann klasse. Ich bin damals zum ergebis gekommen, dass er alle Parameter als statisch behandelt. Habe dann mit nem Pointer rumgetrickst. den kannst du auch direkt an setlength übergeben.
Horschdware Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Fr 10.03.06 00:52 
exzellent.
funktioniert wunderbar.
danke

-> Problem gelöst

_________________
Delphi: XE - OS: Windows 7 Professional x64