Autor Beitrag
martin300
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Sa 04.04.09 12:13 
Die Funktion "maches" soll als Ergebnis ein dynamisches Array liefern. Die Anzahl der Einträge wird in der Funktion dynamisch festgelegt.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  ValueArray = Array of String;

  TForm37 = class(TForm)
  private
    { Private-Deklarationen }
  public
    procedure callmaches;
    function maches():ValueArray;
    { Public-Deklarationen }
  end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function TForm37.maches: ValueArray;
begin
  setLength(ValueArray,1);
  ValueArray[0] := 'Eintrag0';
  result:= ValueArray;
end;


Mein Problem liegt in der Festlegung der Länge von Array "ValueArray". Es würde funktionieren, wenn die Definition innerhalb der Funktion steht, nur so klappt die Rückgabe nicht.
dummzeuch
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 593
Erhaltene Danke: 5


Delphi 5 ent, Delphi 6 bis Delphi XE8 pro
BeitragVerfasst: Sa 04.04.09 12:23 
Das sollte funktionieren:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
function TForm37.maches: ValueArray;
begin
  setLength(Result,1);
  Result[0] := 'Eintrag0';
end;


twm
martin300 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Sa 04.04.09 12:39 
Zitat:

Die Funktion "maches" soll als Ergebnis ein dynamisches Array liefern. Die Anzahl der Einträge wird in der Funktion dynamisch festgelegt.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 04.04.09 16:36 
user profile icondummzeuch hat folgendes geschrieben Zum zitierten Posting springen:
Das sollte funktionieren:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
function TForm37.maches: ValueArray;
begin
  setLength(Result,1);
  Result[0] := 'Eintrag0';
end;
:nixweiss:

user profile iconmartin300 hat folgendes geschrieben Zum zitierten Posting springen:
Mein Problem liegt in der Festlegung der Länge von Array "ValueArray". Es würde funktionieren, wenn die Definition innerhalb der Funktion steht, nur so klappt die Rückgabe nicht.
Falsch, du versuchst einem Datentyp Werte zuzuweisen. Du kannst nur Variablen Werte zuweisen. Kannst ja auch nicht schreiben Integer := 5; ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.