Exclude a value in a set variable System unit
 procedure Exclude(var SetVariable set of SetValues; OneOfSet SetValues);
The Exclude procedure excludes a set value from a set variable.
A set variable is one that can contain 0, some, or all values of a set. When you Exclude a set value in a set variable, you are removing from the included values in the variable.
Exclude is equivalent to the - operator, as shown here :
Exclude(CardHand, JackOfClubs);
CardHand := CardHand - [JackOfClubs];

For example, you can remove a playing card from a players hand - where the hand is based on a set of all playing cards in a deck.
Use Include to add a value to a set variable. This would, for example, allow a card to be added to a player's hand.
Related commands
InUsed to test if a value is a member of a set
IncludeInclude a value in a set variable
SetDefines a set of up to 255 distinct values
 Download this web site as a Windows program.

Example code : Creating a variable containing only positive numbers 0 to 10
  evenNumbers : Set of 0..10;
  i : Integer;
  // Make sure that evenNumbers only contains even numbers
  evenNumbers := [0..10];
  for i := 0 to 10 do
    if (i mod 2) > 0
    then Exclude(evenNumbers, i);

  // Now display the set contents
  for i := 0 to 10 do
    if i in evenNumbers
    then ShowMessage(IntToStr(i)+' is even');
Show full unit code
  0 is even
  2 is even
  4 is even
  6 is even
  8 is even
  10 is even
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page