Forgive me!
Forgot to mention that I modified Magic Script to load "frm" and automatically load all classes registered in RTTI!
I Will send sources!
The project that loads "frm" in MagicScript is in testing!
Lke this:
On Unit:
procedure TfrmPrincipal.ScriptLocal;
var
pscl : TmscrPascalScript;
begin
if OpenDialogPSCL.Execute then begin
//
pscl := TmscrPascalScript.Create(Self);
pscl.Lines.LoadFromFile( OpenDialogPSCL.FileName );
//s
pscl.ScriptPath:= ExtractFilePath(OpenDialogPSCL.FileName);
pscl.IncludePath.Add(ExtractFilePath(OpenDialogPSCL.FileName));
//
pscl.AddRTTI;
pscl.RegisterRTTI2Application; // Register all components
pscl.ProcessDiretives; // Process "diretive" "{FORM someform.frm}" on script
//
if pscl.Compile then begin
pscl.Execute;
end
else begin
memoPainel.Text :='Erro no script';
memoPainel.Lines.Add( pscl.ErrorPos );
memoPainel.Lines.Add( pscl.ErrorMsg );
// memoPainel.Lines.Add( pscl.Lines.Text);
end;
//
end;
end;
On Script:
PROGRAM ms;
{FORM ms.frm} // Diretive to load form "ms.frm"} That's OK!!!
Uses 'msf.pscl';
procedure Click1(Sender: TObject);
begin
Self.Caption := 'Script ON';
Self.Label1.Caption := 'Label: ' + TimeToStr(NOW);
Self.Edit1.Text := 'Glórias a DEUS!!!';
Self.memo1.lines.Add(Self.Name);
msfProc('Augusto');
end;
procedure Click2(Sender: TObject);
begin
if ExecScript(Self,'ms.pscl') then
Self.memo1.lines.add('execScript Ok')
else Self.memo1.lines.add('execScript ERRO');
end;
begin
Self.Caption := 'Caption do Script';
Self.Button1.OnClick := @click1;
Self.Button2.OnClick := @click2;
Self.Caption := Self.Name;
Self.Show;
end.
This works SO FINE!!!
Thanks Sir!