Autor Beitrag
THF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Di 22.02.05 18:31 
Hallo,

wie kann ich eine ARRAY-Variable als Parameter in einer Procedure übergeben,
und wie rufe die Procedure wieder auf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Procedure Test( var Testvariable :array of Integer;var Testvariable2 : array of TTest);
........         
begin

end;

ProcedureTform.Button1Click(Sender: TObject);
begin
Test(Testvariable[1],Testvariable2[1]);
end;

Gruß

THF

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am Di 22.02.2005 um 17:35
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Di 22.02.05 18:37 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TArrayOfInteger = array of integer;
  TArrayOfTTest = array of TTest;

procedure Test(var Testvariable: TArrayOfIntegervar Testvariable2 : TArrayOfTTest);
........         
begin

end;




MrSaint

EDIT: hatte beim ersten Parameter vergessen, dass das auch ein Array ist :oops:

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems


Zuletzt bearbeitet von MrSaint am Di 22.02.05 19:57, insgesamt 1-mal bearbeitet
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Di 22.02.05 19:31 
Hallo MrSaint,

kannst Du mir vielleicht noch erklären,
wie ich die Procedure dann wieder aufrufe ?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Procedure Tform.Button1Click(Sender: TObject);  
begin  
Test(Testvariable[1],Testvariable2[1]);  
end;

Gruß

THF

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Di 22.02.05 19:59 
Etwa so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);  
var
  aTestvariable   : TArrayOfInteger;
  aTestvariable2  : TArrayOfTTest;
begin  
  Test(aTestvariable, aTestvariable2); 
end;

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Mi 23.02.05 08:03 
Hallo,

die eigentliche Array-Variable kann man wohl nicht als Parameter übergeben ?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);    
begin    
  Test(Testvariable[1],Testvariable2[1]);    
end;

Gruß
THF

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Mi 23.02.05 10:30 
Wie sind Testvariable und Testvariable2 denn deklariert? Du musst halt einen TArrayOfInteger und einen TArrayOfTTest übergeben...


MrSaint

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Mi 23.02.05 19:25 
Hallo,

also so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);    
var  
  Testvariable[1]  : TArrayOfInteger;  
   Testvariable2[1] : TArrayOfTTest;  
begin    
   Test(Testvariable[1],Testvariable2[1]);     
  end;

Gruß

THF
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Mi 23.02.05 19:56 
hast du das so schonmal versucht zu compilieren?!? Lern erst mal ein bisschen Delphi Grundlagen! Aber ich will ja mal net so sein: Lass einfach immer das "[1]" weg, dann ist gut!

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems
THF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Vista
Delphi 2005 professional
BeitragVerfasst: Do 24.02.05 08:12 
Hallo,

aber wie mache ich das wenn ich z.B. ein Array mit 10 Figuren habe und möchte die Figur[5] als Parameter der Procedure übergeben ?

Gruß

THF

Moderiert von user profile iconTino: Überflüssige Absätze entfernt.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 24.02.05 09:09 
Das soll jetzt nur ein Beispiel sein.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TFigur = record
    ValueA: Integer;
    ValueB: Integer;
  end;

ausblenden Delphi-Quelltext
1:
2:
type
  TFiguren = array of TFigur;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure Test(var AFigur: TFigur);
begin
  AFigur.ValueA := 10;
  AFigur.ValueB := 20;
end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
var
  Figuren: TFiguren;
begin

  SetLength(Figuren, 10);
  Test(Figuren[5]);
  SetLength(Figuren, 0);

end;

_________________
Ciao, Sprint.