PaxScripter 'Hello'application written in Delphi.

demo_hello1.jpg arrowr.jpg demo_hello2.jpg
unit WinForm1;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, PaxScript.Net;

type
  TWinForm1 = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    components: System.ComponentModel.IContainer;
    PaxScripter1: PaxScript.Net.PaxScripter;
    Button1: System.Windows.Forms.Button;
    procedure InitializeComponent;
    procedure Button1_Click(sender: System.Object; e: System.EventArgs);
    procedure PaxScripter1_OnChangeState(sender: PaxScript.Net.PaxScripter; e: PaxScript.Net.ChangeStateEventArgs);
  {$ENDREGION}
  strict protected
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm1))]

implementation

{$REGION 'Windows Form Designer generated code'}
procedure TWinForm1.InitializeComponent;
begin
  Self.components := System.ComponentModel.Container.Create;
  Self.PaxScripter1 := PaxScript.Net.PaxScripter.Create(Self.components);
  Self.Button1 := System.Windows.Forms.Button.Create;
  Self.SuspendLayout;
  //
  // PaxScripter1
  //
  Include(Self.PaxScripter1.OnChangeState, Self.PaxScripter1_OnChangeState);
  //
  // Button1
  //
  Self.Button1.Location := System.Drawing.Point.Create(48, 40);
  Self.Button1.Name := 'Button1';
  Self.Button1.TabIndex := 0;
  Self.Button1.Text := 'Click Me';
  Include(Self.Button1.Click, Self.Button1_Click);
  //
  // TWinForm1
  //
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
  Self.ClientSize := System.Drawing.Size.Create(192, 102);
  Self.Controls.Add(Self.Button1);
  Self.Name := 'TWinForm1';
  Self.Text := 'HelloApp';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm1.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm1.Create;
begin
  inherited Create;
  InitializeComponent;
end;

procedure TWinForm1.PaxScripter1_OnChangeState(sender: PaxScript.Net.PaxScripter;
  e: PaxScript.Net.ChangeStateEventArgs);
begin
    if e.OldState = ScripterState.Init then
  begin
    paxScripter1.RegisterInstance('Button1', Button1);
    paxScripter1.AddModule('1');
    paxScripter1.AddCode('1', 'Button1.Text = "Hello";');
  end
  else if e.NewState = ScripterState.Error then
    MessageBox.Show('Error ' + sender.Error_List[0].Message);
end;

procedure TWinForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
  PaxScripter1.Run(RunMode.Run, []);
end;

end.


Copyright © 2005-2022 Alexander Baranovsky. All rights reserved.