ex111.pp 789 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. program Example111;
  2. { Program to demonstrate the Include/Exclude functions }
  3. Type
  4. TEnumA = (aOne,aTwo,aThree);
  5. TEnumAs = Set of TEnumA;
  6. Var
  7. SA : TEnumAs;
  8. Procedure PrintSet(S : TEnumAs);
  9. var
  10. B : Boolean;
  11. procedure DoEl(A : TEnumA; Desc : String);
  12. begin
  13. If A in S then
  14. begin
  15. If B then
  16. Write(',');
  17. B:=True;
  18. Write(Desc);
  19. end;
  20. end;
  21. begin
  22. Write('[');
  23. B:=False;
  24. DoEl(aOne,'aOne');
  25. DoEl(aTwo,'aTwo');
  26. DoEl(aThree,'aThree');
  27. Writeln(']')
  28. end;
  29. begin
  30. SA:=[];
  31. Include(SA,aOne);
  32. PrintSet(SA);
  33. Include(SA,aThree);
  34. PrintSet(SA);
  35. Exclude(SA,aOne);
  36. PrintSet(SA);
  37. Exclude(SA,aTwo);
  38. PrintSet(SA);
  39. Exclude(SA,aThree);
  40. PrintSet(SA);
  41. end.