paxScript Demo. Cross-language Programming. Using paxPascal classes in paxJavaScript scripts.


Let's consider a paxPascal script:
program Demo;
type
  TRandomPoint = record
    X: Integer = Random(100);
    Y: Integer = Random(100);
    function TRandomPoint(): TRandomPoint;
    begin
      result := Self;
    end;
  end;

   TPascalClass = class(TObject)
   private
     fProp: Integer = 10;
    public
     constructor Create;
     function TPascalClass: TPascalClass; // to use it in paxJavaScript or paxC
     property Prop: Integer read fProp;
   end;

constructor TPascalClass.Create;
begin
  inherited;
end;

function TPascalClass.TPascalClass: TPascalClass;
begin
  result := Self;
end;

begin
end.
You can use TRandomPoint, TPascalClass types in paxJavaScript scripts. For example:
x = new Demo.TPascalClass();
print x.Prop;
p = new Demo.TRandomPoint();
print p.X;
print p.Y;


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