Board index » delphi » Ok Question#2--Custom Events--Left side cannot be assigned to

Ok Question#2--Custom Events--Left side cannot be assigned to

I have created a Method pointer like:

TOnTestCompleted = procedure(Rslt:TCheckResult)of object;

In my Base class I've created a property for the method pointer:

property OnTestCompleted:TOnTestCompleted read FOnTestCompleted write FOnTestCompleted;

I've also created a procedure that will assign a value to FOnTestCompleted as:

procedure DoTestCompletion(rslt:TCheckResult);dynamic;

After a certain method, I fire the event by calling
DoTestCompletion.

However when I create an instance of a class derived from my
base class and try to assign the event as:

OnTestCompleted(FSysResult.Rst):=writeToGrid(FSysResult.Rst);

I get "Left side cannot be assigned to" error.  Can anyone spot the errors of my ways (hopefully it won't be as stupid as my first post)?

thanks,
Bill

 

Re:Ok Question#2--Custom Events--Left side cannot be assigned to


Quote
>OnTestCompleted(FSysResult.Rst):=writeToGrid(FSysResult.Rst);

Remove the parameters otherwise the compiler assumes that you want to
call the event instead of assigning its address.

OnTestCompleted := writeToGrid;

Regards from Germany

Franz-Leo

Re:Ok Question#2--Custom Events--Left side cannot be assigned to


Quote
>Remove the parameters otherwise the compiler assumes that you want to
>call the event instead of assigning its address.

>OnTestCompleted := writeToGrid;

Thanks, Franz-Leo-- Works perfectly.

Other Threads