procedure types in Turbo Delphi .net

Please discuss general Delphi programming topics here.

procedure types in Turbo Delphi .net

Postby rhartl » June 27th, 2007, 4:40 pm

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 ](*,)
rhartl
Active Member
Active Member
 
Posts: 11
Joined: June 12th, 2006, 2:30 am

Postby Kambiz » June 27th, 2007, 7:53 pm

The proper assignment is:

Code: Select all
MyClass.AVar := AProc;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 14 guests

cron