Autor Beitrag
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Fr 13.06.03 09:21 
Wie kann ich eine Referenz auf ein Array erstellen. Wenn ich es genauso deklariere, sagt er: "inkompatible typen!"

also
ausblenden Quelltext
1:
2:
3:
4:
5:
var refArr: array of TTest;

begin

refArr:=arrListe;   //arrListe ist global deklariert


Wie macht man so etwas?

_________________
MFG Rool
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Fr 13.06.03 09:33 
Du musst einen neuen Typen anlegen, denn wenn die beiden Variablen nicht in der selben "Zeile" deklariert sind, sind sie nicht kompatibel.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
var
  a, b: array of TTest;

a := b; // is OK



var 
  a: array of TTest;
  b: array of TTest;

a := b; // Fehler



type
  TTestDynArray = array of TTest;
var
  a: TTestDynArray;
  b: TTestDynArray;

a := b; // ist OK

Das ist nun mal der Pascal-Standard den man akzepieren muss.

_________________
Ist Zeit wirklich Geld?
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Fr 13.06.03 15:18 
Titel: ..
Alles klar! Ist ja sehr merkwürdig! Aber DANKE!

_________________
MFG Rool
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Fr 13.06.03 15:32 
Titel: ...
Aber das ist ja gar keine Referenz! Wenn ich in a irgendwas drin stehen habe und dann
b:=a
setzte,

und dann in b etwas ändere, ändert sich das in a NICHT!!!

_________________
MFG Rool
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Fr 13.06.03 15:52 
Bei dynamisch Arrays müsste das schon so sein. Hast du vielleicht ein festgelegtes Array (Array[x..y] of XX) deklariert?

_________________
Ist Zeit wirklich Geld?
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: So 15.06.03 16:21 
Titel: ne
ne, ist n dynamisches!

_________________
MFG Rool
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: So 15.06.03 16:25 
Bei dynamischen Arrays wird es nur eine Referenz, habe dasselbe Problem vor kurzem gehabt, dass plötzlich beides gleich war und ich nicht wusste warum, nur weil ich einen Fehler bei der Datenübergabe gemacht habe. Typen sind bei solchen Zuweisungen im Normalfall immer Referenzen.