unit MainForm;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Layouts, FMX.Memo, FMX.Edit,
  atScript, atScripter, FMX.ScriptForm, FMX.ScripterInit;

type
  TfmMain = class(TForm)
    Layout1: TLayout;
    Memo1: TMemo;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    Scripter: TatScripter;
  public
    { Public declarations }
  end;

var
  fmMain: TfmMain;

implementation

{$R *.fmx}

procedure TfmMain.Button1Click(Sender: TObject);
begin
  Scripter.SourceCode := Memo1.Lines;
  Scripter.Execute;
end;

procedure TfmMain.FormCreate(Sender: TObject);
begin
  Scripter := TatScripter.Create(Self);

  // Define TScriptForm to use methods like Show
  // Use roInclude so that current Create method is not overriden
  Scripter.DefineClassByRTTI(TScriptForm, roInclude);
  Scripter.DefineClassByRTTI(TButton);
  Scripter.DefineClassByRTTI(TEdit);
  Scripter.DefineClassByRTTI(TLabel);
  Scripter.AddConstant('mrOk', mrOk);
  Scripter.AddConstant('mrCancel', mrCancel);
end;

end.
