我正在尝试用dwscript创建一个模态表单.我使用ExposeRtti注册表单,然后执行脚本,但在Script.Compile期间它在"堆栈溢出"时失败.有没有人有这个错误的解决方案.
我当然希望我不必手动注册所有TForm属性和函数,就像我们必须使用remobjects PascalScript一样,在这个时代它会让我们难看,就像避免那样......
dwscript可以这样做,还是形式超出了dwscript的范围(在这个阶段?)?
procedure TMainForm.Button1Click(Sender: TObject);
var AdwsProgramExecution: IdwsProgramExecution;
ADelphiWebScript: TDelphiWebScript;
AdwsProgram: IdwsProgram;
AdwsUnit: TdwsUnit;
begin
AdwsUnit := TdwsUnit.Create(nil);
ADelphiWebScript := TDelphiWebScript.Create(nil);
try
AdwsUnit.UnitName := 'ShowModalTest';
AdwsUnit.Script := ADelphiWebScript;
AdwsUnit.ExposeRTTI(TypeInfo(TObject)); //Otherwise GetOnAlignInsertBefore error when 'compiling'
AdwsUnit.ExposeRTTI(TypeInfo(TForm)); //Want t ocreate a form
AdwsProgram := ADelphiWebScript.Compile('procedure TestShowModal; begin TForm.Create(nil).ShowModal; end; end.'); //Stack overflow
if AdwsProgram.Msgs.Count = 0 then
begin
AdwsProgramExecution := AdwsProgram.Execute;
MEResult.Lines.Text := AdwsProgramExecution.Result.ToString;
end
else
MEResult.Lines.Text := AdwsProgram.Msgs.AsInfo;
finally
ADelphiWebScript.Free;
AdwsUnit.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)