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 t开发者_如何学Gohink 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?
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.
精彩评论