TPaxScripter Demo. Registering overloaded routines and routines which have default parameters.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, PaxScripter, PaxPascal, BASE_PARSER;

type

  TForm1 = class(TForm)
    Memo1: TMemo;
    PaxScripter1: TPaxScripter;
    PaxPascal1: TPaxPascal;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure TestOverload(lVal: Boolean); overload;
    procedure TestOverload(const cVal: String); overload;
    procedure TestDefParam(const cVal: String = 'abc');
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

uses Imp_Classes, Imp_Dialogs;

procedure TForm1_TestOverload1(lVal: Boolean);
begin
  TForm1(_Self).TestOverload(lVal);
end;

procedure TForm1_TestOverload2(const cVal: String);
begin
  TForm1(_Self).TestOverload(cVal);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   RegisterClassType(TForm1, -1);
   RegisterMethod(TForm1,
       'procedure TestOverload(lVal: Boolean);',
       @TForm1_TestOverload1, fake);
   RegisterMethod(TForm1,
       'procedure TestOverload(const cVal: String);',
       @TForm1_TestOverload2, fake);
   RegisterMethod(TForm1,
       'procedure TestDefParam(cVal: String = ''abc'');',
       @TForm1.TestDefParam);

   PaxScripter1.ResetScripter;
   PaxScripter1.RegisterObject('Form1',Self);
   PaxScripter1.AddModule('main','paxPascal');
   PaxScripter1.AddCode('main',Memo1.Lines.Text);
   PaxScripter1.Run;
end;

procedure TForm1.TestOverload(lVal: Boolean);
begin
   If lVal Then begin
      ShowMessage('True');
   end else begin
      ShowMessage('False');
   end;
end;

procedure TForm1.TestDefParam(const cVal: String = 'abc');
begin
   ShowMessage(cVal);
end;

procedure TForm1.TestOverload(const cVal: String);
begin
   ShowMessage(cVal);
end;

end.


Copyright © 1999-2006 VIRT Laboratory. All rights reserved.