The reserved word in:
true]] if the value belongs to the set and [[False|
false]] if the value does not belong to the set.
- It is also used with the reserved word
forin for-in loop. - It is also usable in
uses‑clauses.
Example
program projectin;
uses SysUtils, TypInfo;
type
Berry = (Blueberry, FlyHoneysuckle, Lingonberry, Raspberry, Snowberry, Strawberry);
Berries = set of berry;
var
basket: Berries;
someberry: berry;
str: string;
i: integer;
begin
basket := [];
writeLn('Choose a berry from the following berries into your basket');
repeat
i := 1;
for someberry in berry do
begin
Str := GetEnumName(TypeInfo(Berry),ord(someberry));
writeln(i,' : ',Str);
inc(i);
end;
writeln('0 : exit');
writeln;
readln(i);
if i>0 then
begin
someberry :=Berry(i-1);
Include(basket, someberry);
end;
until i=0;
if (FlyHoneysuckle in basket) or (Snowberry in basket) then
begin
writeln('You have poisonous berries in your basket');
if FlyHoneysuckle in basket then
writeln('Your basket has a poisonous Fly honeysuckle!') ;
if Snowberry in basket then
writeln('Your basket has a poisonous Snowberry!');
end;
writeln('So you had these berries in your basket:');
for someberry in basket do
begin
Str := GetEnumName(TypeInfo(Berry), Ord(someberry));
writeln(Str);
end;
readln;
end.