Autor Beitrag
DelphMan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 08.10.06 15:02 
Hallo,


es gibt folgende Klasse:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
type
  TSlot = class(TThread)
    function Channel:Integer;
  private
  protected
    procedure Execute; override;
  public
    constructor Create(new_id:integer);
    destructor Destroy; override;

    var id : integer;
end;


Und dann noch das Array:

ausblenden Delphi-Quelltext
1:
var Slots:array[1..480] of TSlot;					


Wieso kann ich keinen Pointer auf die Funktion
Channel erhalten? Auf normale Funktionen kann
man ohne Weiteres Pointer erhalten, wieso in
meinem Falle nicht?
Ich erhalte immer E2036 Variable erforderlich.

Siehe hier:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var P:Pointer, id:integer;

begin
  id:=9;
  P:=@Slots[id].Channel; // GEHT NICHT!
end;



Nachtrag: Selbstverständlich wird das Array zuvor noch initialisiert:

ausblenden Delphi-Quelltext
1:
2:
for i:=1 to 480 do
Slots[i]:=TSlot.Create(i);



Vielen Dank!

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 08.10.06 15:24 
Hallo,

Und wenn du die Funktion in public schiebst?

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
DelphMan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57



BeitragVerfasst: So 08.10.06 15:28 
Hallo,

das klappt leider auch nicht.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 08.10.06 19:14 
Warum steht die Funktion in unter keinem SIchtbarkeitsbereich (private,public etc.) bei dir sondern darüber?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
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: Do 12.10.06 23:12 
Du kannst keinen Pointer auf diese Methode erhalten, weil deine Syntax dafür nicht stimmt. Delphi prüft bei Methoden etwas energischer die Typen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
type TChannelFunc = Fcuntion : Integer of object;
Var P: TChannelFunc;

P := @Slot[i].Channel;


Dann sollte es gehen ...

_________________
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.