枚举

type
  TSize = (szS, szM, szL);

  //a record helper adds methods
  //to an enumeration
  TSizeHelper = record helper for TSize
  public
    function NextSize: TSize;
    function AsText: string;
  end;

function TSizeHelper.NextSizeTSize;
begin
  if Self = High(TSizethen
    Result := Low(TSize)
  else
    Result := Succ(Self);
end;

function TSizeHelper.AsTextstring;
const
  Names: array[TSizeof string =
    ('S''M''L');
begin
  Result := Names[Self];
end;

var
  Middle, Next1, Next2: TSize;
begin
  Middle := szM;

  Next1 := Middle.NextSize;
  //Next1 is szL
  Next2 := Next1.NextSize;
  //Next2 is szS

  WriteLn('next1 is ', Next1.AsText);
  //next1 is L
  WriteLn('next2 is ', Next2.AsText);
  //next2 is S
end.