Page 1 of 1

procedure types in Turbo Delphi .net

PostPosted: June 27th, 2007, 4:40 pm
by rhartl
I have written an object under Turbo Delphi that has a property that I would like to assign to a procedure type, but the compiler refuses to compile. It is unclear to me what I am doing wrong, maybe you all can help.

The type is declared like so...

Type

TProc = Procedure(Const S: String) of Object;

The class declaration looks like this

TMyClass = ....

Private
FVar : TProc;

...
Property AVar : TProc Write FVar;

Then there is this procedure declaration...

Procedure AProc(Const S :String);

begin

MessageBox(S,mtError,[mbOk],0);

end;

The following assignment snags the compiler ...

MyClass.AVar := AProc('String...');

saying I am trying to assign the wrong type. Any ideas.

-- Rich ](*,)

PostPosted: June 27th, 2007, 7:53 pm
by Kambiz
The proper assignment is:

Code: Select all
MyClass.AVar := AProc;