Search Results for

    Show / Hide Table of Contents

    Classes

    You cannot define a class inside the script, but you can use the external classes defined in add-in modules or your application. This is an example from the DEMOS\Main demo:

    var
      f: TForm;
      b: TButton;
    
    procedure ButtonClick(Sender: TButton);
    begin
      ShowMessage(Sender.Name);
      f.ModalResult := mrOk;
    end;
    
    // there is no need to use all the parameters in event handlers
    // because no type checking is performed here
    procedure ButtonMouseMove(Sender: TButton);
    begin
      b.Caption := 'moved over';
    end;
    
    begin
      f := TForm.Create(nil);
      f.Caption := 'Test it!';
      f.BorderStyle := bsDialog;
      f.Position := poScreenCenter;
    
      b := TButton.Create(f);
      b.Name := 'Button1';
      b.Parent := f;
      b.SetBounds(10, 10, 75, 25);
      b.Caption := 'Test';
    
      b.OnClick := @ButtonClick; { same as b.OnClick := 'ButtonClick' }
      b.OnMouseMove := @ButtonMouseMove;
    
      f.ShowModal;
      f.Free;
    end.
    

    As you can see there is no difference between PascalScript and Delphi code. You can access any property (simple, indexed or default) or method. All the object's published properties are accessible from the script by default. Public properties and methods need the implementation code - that's why you can access it partially (for example, you cannot access the TForm.Print method or TForm.Canvas property because they are not implemented).

    You can add your own classes - see "Scripting" chapter for details.

    Back to top © Copyright Fast Reports Inc.