作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
想象这个脚本代码:
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;
这有可能吗?
最佳答案
您正在寻找的可能是可用作的 IInfo 接口(interface)
Exec.Info.Func['B'].Call([])
http://code.google.com/p/dwscript/wiki/FirstSteps 中还有更多示例(向下滚动到函数),以及单元测试中的一些使用代码(尤其是 UdwsUnitTests,请参阅 CallFunc 方法)。
IInfo 作为 Delphi 端查询 RTTI、调用函数、直接获取/设置变量、实例化脚本端对象等的主要方式。不过,它的大部分示例代码目前都在单元测试中。
关于德尔福网页脚本: How to call a Script Function from Delphi Code within an Execution Context?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5966064/
我是一名优秀的程序员,十分优秀!