TCallback = procedure;
FFForm = class(TObject)
procedure OnCreate(Callback: TCallback);
end;
procedure TForm1.PSScript1Compile(Sender: TPSScript);
var CustomClass: TPSCompileTimeClass;
begin
Sender.AddFunction(@MWrites, 'procedure Writes(const s: string)');
[...]
procedure MWrites(const s: string);
begin
showmessage(s);
end;
procedure FFForm.OnCreate(Callback: TCallback);
begin
ShowMessage('1');
Callback;
end;
My code in PascalScript:
procedure FormCreate;
begin
Writes('2');
end;
var Form: FForm;
begin
Form := FForm.Create;
Form.OnCreate(@FormCreate);
Form.Free;
end.
My function FFForm.OnCreate is executed just fine and I can see the showmessage('1') showing a dialogbox saying "1" but the Callback is not executed and the code "Writes('2')" is not executing.
Code in Lazarus:
My code in PascalScript:
My function FFForm.OnCreate is executed just fine and I can see the showmessage('1') showing a dialogbox saying "1" but the Callback is not executed and the code "Writes('2')" is not executing.
How I can I execute this callback from Lazarus?