2
votes

I using RemObjects Pascal Script component for Delphi XE, i've the following code:

type
  ITest = interface(IInterface)
  ['{7762A355-052F-449D-8347-01B59E2D2738}']
    procedure Execute;
  end;

  TTest = class(TInterfacedObject, ITest)
  private
    procedure Execute;
  end;


procedure TForm1.Button3Click(Sender: TObject);
var T: ITest;
    o: TPSScript;
begin
  T := TTest.Create;  

  o := TPSScript.Create(nil);
  try
    o.Script.Text :=
      'begin '                                    + sLineBreak +
      '  T.Execute; '                             + sLineBreak +
      'end.';
    Execute(o);
  finally
    o.Free;
  end;
end;


My question is how to register the interface variable T (instance of ITest) into pascal script so that I can invoke the T.Execute in pascal script?

2

2 Answers

2
votes

first you need to register your interface type in the OnCompile event:

with ps.Compiler.AddInterface(ps.Compiler.FindInterface('IUnknown'), StringToGuid('{7762A355-052F-449D-8347-01B59E2D2738}'), 'ITest') do
  RegisterMethod('procedure Execute;', cdRegister);
ps.AddRegisteredVariable('data', 'ITest');

then in OnExecute:

SetVariantToInterface(ps.GetVariable('data'), mydata);
0
votes

It's described on their wiki, here the article. Maybe somebody can summarize it, who is into this stuff. I just found it through google.