I have looked into this before and I can't quite work out how to assign the procedure.

Examples show something like this:-

type TDebugProc = procedure(Text: string);

This is in effect a forward declaration on Form2 for a procedure that Form1 will pass it.

So I declare a variable on Form2:-

var
MyDebugProc: TDebugProc;

And I can call it like this:-

MyDebugProc('TEST MESSAGE');



The question is how to I populate this variable on Form2, from Form1 when the procedure declaration on Form1 is:-

TForm1.WriteDebug(Text: String);
begin
{DO SOME STUFF}
end;

??

On Form1 I want to do something like this:-

Form2.MyDebugProc := @WriteDebug;