3

Imaging this scripting code:

procedure A;
begin
  CallToDelphi;
end;

procedure B;
begin
  // do something
end;

I have exposed the procedure "CallToDelphi" to the script. So when it is called, I'm back from script in my Delphi code. I now want to call the script procedure "B" from my Delphi Code. I think is must be hidden in the IdwsProgramExecution-Context. But I didn't found anything yet. I'm looking for a something like that:

procedure CallToDelphi;
begin
  Exec.Invoke('B', []); // Exec is IdwsProgramExecution
end;

Is this somehow possible?

Steffen Binas
  • 1,463
  • 20
  • 30

1 Answers1

2

What you're looking for is probably the IInfo interface which can be used as

Exec.Info.Func['B'].Call([])

There are some more samples in http://code.google.com/p/dwscript/wiki/FirstSteps (scroll down to functions), and also some usage code in the unit tests (UdwsUnitTests notably, see the CallFunc method).

The IInfo serves Delphi-side as the primary way to query RTTI, invoke functions, get/set variables directly, instantiate script-side objects, etc. Most of the sample code for it is currently in the unit tests though.

Eric Grange
  • 5,931
  • 1
  • 39
  • 61
  • Thank you. I already browsed through the unit tests, but didn't find it. Thanks for your guidance. Now it's clear. This is exactly what I was looking for. – Steffen Binas May 12 '11 at 07:20