gpt4 book ai didi

德尔福网页脚本: How to call a Script Function from Delphi Code within an Execution Context?

转载 作者:行者123 更新时间:2023-12-03 15:57:22 25 4
gpt4 key购买 nike

想象这个脚本代码:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com