I'm trying to create a modal form with dwscript. Im registering the form with the ExposeRtti, then execute the script but it fails on a "Stack overflow" during the Script.Compile. Does anybody have a solution for this error.
I surely hope i dont have to register all the TForm properties and functions manually like we have to with remobjects PascalScript, it would we ugly in this era, like to avoid that..
Can dwscript do this, or are forms simply beyond the scope of dwscript (at this stage?)?
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;