unit SystemSizeOf;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: SystemSizeOf
// Routine: System.SizeOf

// BeginCode
{
This example makes a record.  Reports the size of the reocrd,
fills it and reports the contents.
}
type
  CustRec = record
    Name: string[30];
    Phone: string[14];
  end;

procedure TForm1.Button1Click(Sender: TObject);
 var
  P: ^CustRec;
  size: Integer;
begin
  GetMem(P, SizeOf(CustRec));
  Canvas.TextOut(10, 10, 'The size of the record is ' + IntToStr(SizeOf(CustRec)));
  P.Name := 'a12345678901234567890123456789';
  P.Phone := '9,1,4085551212';
  Canvas.TextOut(10, 40, 'Name was assigned this string: ' + P.Name);
  Canvas.TextOut(10, 70, 'Phone was assigned this string: ' + P.Phone);
  size := SizeOf(CustRec);
  FreeMem (P, size);
end;
// EndCode
// EndExample: SystemSizeOf
end.
