marco.records.pas

来自「source code for Marco Cantu s book Delph」· PAS 代码 · 共 69 行

PAS
69
字号
unit Marco.Records;

interface

type
  TMyRecord = record
  private
    one: string;
    two: Integer;
    three: Char;
  public
    procedure Print;
    // constructor Create; // causes error
    constructor Create (aString: string);
    procedure Init (aValue: Integer);
  end;

type
  TAnotherRecord = packed record
  private
    one: string;
    two: Integer;
    three: Char;
  public
    procedure Print;
    procedure Init (aValue: Integer);
  end;

implementation

uses
  SysUtils;

{ TMyRecord }

constructor TMyRecord.Create (aString: string);
begin
  writeln ('TMyRecord.Create called');
  one := aString;
  two := 2;
  three := '3';
end;

procedure TMyRecord.Init(aValue: Integer);
begin
  two := aValue;
  one := IntToStr (aValue);
end;

procedure TMyRecord.Print;
begin
  writeln (one, ' - ' , two, ' - ', three);
end;

{ TAnotherRecord }

procedure TAnotherRecord.Init(aValue: Integer);
begin
  two := aValue;
  one := IntToStr (aValue);
end;

procedure TAnotherRecord.Print;
begin
  writeln (one, ' - ' , two, ' - ', three);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?