2
从以下脚本代码中,我调用Delphi中的Run过程,该过程调用也在Delphi中的showmodal过程。 当从新创建的模态对话框中调用Button1Click()时,全局变量sl未被实例化。从模态对话框调用脚本函数给出“对象未实例化”
脚本代码。
var sl : TStringList;
procedure Run();
begin
sl := TStringList.create();
ShowModal;
showMessage(sl.Text);
sl.free;
end;
procedure Button1Click();
begin
sl.Add('DWS');
end;
德尔福方面的代码。
1)呼叫运行()
FExec := FCompiledScript.BeginNewExecution;
FExec.Info.Func['Run'].Call([]);
FExec.EndProgram;
2)的ShowModal评估和演示
Form1 := TForm1.Create(nil);
Form1.Exec := FExec;
Form1.ShowModal;
3)使用相同的IdwsProgramExecution对象
FExec.Info.Func['Button1Click'].Call([]);
在此从模态对话框调用Button1Click点我得到错误“对象未实例化”。关闭对话框后,我得到了showmessage,没有任何东西。
您可以将完整的代码发布到您的表单和您的脚本,或至少一个完整的,可编译的例子,将展示此行为?我看到的所有东西都看起来像它应该工作,但是如果我有实际的代码运行,我可以测试它,看看发生了什么。 –