Structures (records)

uses System.SysUtils;

type
  TPoint = record
    X, Y: Integer;
    function ToText: string;
    //unlike Java records, methods may
    //change the record's fields
    procedure Move(Right, Down: Integer);
  end;

function TPoint.ToTextstring;
begin
  Result := Format('x = %d; y = %d', [X, Y]);
end;

procedure TPoint.Move(Right, Down: Integer);
begin
  X := X + Right;
  Y := Y + Down;
end;

var
  P1TPoint;
begin
  P1.X := 1;
  P1.Y := 2;
  WriteLn('str1 is 'P1.ToText);
  //str1 is 'x = 1; y = 2'

  P1.Move(5-1);
  WriteLn('str2 is 'P1.ToText);
  //str2 is 'x = 6; y = 1'
end.