Autor Beitrag
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 15.12.04 16:07 
Hallo Leute!

Ich habe folgende Funktion:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function ListFiles({...} Files: array of TFileBlock): Integer;
var
  {...}
begin
  {...}
  // Variablen initialisieren
  {...}
  SetLength(Files, 0);

  {...]
  end;


Bei SetLength kommt der Fehler:

Delphi Debugger hat folgendes geschrieben:

[Fehler] DSAS.dpr(472): Inkompatible Typen


TFileBlock ist vom Typ Record mit Strings! Diese sind allerdings von ihrer Größe begrenzt!


Danke!

Alstar
Pr0g
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: Mi 15.12.04 16:47 
Hallo,

du kannst einer Prozedur nicht direkt ein Array übergeben, du musst zuerst einen Typ anlegen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
type
  TFileBlockArray = Array of TFileBlock;

function ListFiles({...} Files: TFileBlockArray): Integer;


MfG Pr0g
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 15.12.04 21:46 
Zur Erklärung:

Wenn du einer Prozedure einen Parameter Array of IrgendEinTyp übergibst, interpretiert Delphi dies als "Offenen Array Parameter" und nicht als "Dynamisches Array". Du kannst also beim Funktionsaufruf an der angegebenen Stelle in Eckige Klammern beliebig viele Elemente schreiben und Delphi würde dir daraus ein einzelnes Array bauen. Siehe DOH für genauere Informationen zu den Unterschieden.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.