I am having a problem with the example from this article. The article explains how to import your own classes so they can be called from a Pascal Script. I am importing my custom class but cannot get Pascal Script to recognize the 'Create' and 'Free' functions.
My plugin:
TMyPsPlugin = class
public
procedure PrintMessage(const AMessage: String);
end;
procedure TMyPsPlugin.PrintMessage(const AMessage: String);
begin
ShowMessage(AMessage);
end;
My app:
procedure TForm1.FormCreate(Sender: TObject);
var
Plugin: TPSPlugin;
begin
Plugin := TPSImport_MyPsPlugin.Create(Self);
TPSPluginItem(ps.Plugins.Add).Plugin := Plugin;
end;
procedure TForm1.bCompileClick(Sender: TObject);
begin
ps.Script.Text := mScript.Text;
if ps.Compile then
begin
if ps.Execute then
ShowMessage('Done.')
else
ShowMessage('Execution Error: ' + Ps.ExecErrorToString);
end
else
HandleError;
end;
My Script:
program test;
var
Plugin: TMyPsPlugin;
begin
Plugin := TMyPsPlugin.Create;
Plugin.PrintMessage('Hello');
Plugin.Free;
end.
Error Messages:
[Error] (5:25): Unknown identifier 'Create'
[Error] (7:10): Unknown identifier 'FREE'