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.NextSize: TSize;
begin
if Self = High(TSize) then
Result := Low(TSize)
else
Result := Succ(Self);
end;
function TSizeHelper.AsText: string;
const
Names: array[TSize] of 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.