Delphi Web 脚本:如何在执行上下文中从 Delphi 代码调用脚本函数?
想象一下这个脚本代码:
procedure A;
begin
CallToDelphi;
end;
procedure B;
begin
// do something
end;
我已经向脚本公开了过程“CallToDelphi”。所以当它被调用时,我从 Delphi 代码中的脚本返回。我现在想从我的 Delphi 代码中调用脚本过程“B”。 我认为它必须隐藏在 IdwsProgramExecution-Context 中。但我还没有发现任何东西。我正在寻找类似的东西:
procedure CallToDelphi;
begin
Exec.Invoke('B', []); // Exec is IdwsProgramExecution
end;
这有可能吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找的可能是 IInfo 接口,可用作
http://code.google.com/p/dwscript/wiki/FirstSteps(向下滚动到函数),以及单元测试中的一些使用代码(尤其是 UdwsUnitTests,请参阅 CallFunc 方法)。
IInfo 作为 Delphi 端查询 RTTI、调用函数、直接获取/设置变量、实例化脚本端对象等的主要方式。不过,它的大部分示例代码目前都在单元测试中。
What you're looking for is probably the IInfo interface which can be used as
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.