RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Exclude Function

Removes an element from a Delphi set or removes an event handler in .NET applications.

Pascal
procedure Exclude(var S: set of T; I: T);
C++
Exclude(set of T S, T I);

When the first argument of Include is a set type variable, the Exclude procedure removes an element from the set. If S is a set type variable, and I is an expression of a type compatible with the base type of S. then Exclude(S,I) corresponds to S := S - [I] but the Exclude procedure generates more efficient code.  

On the .NET platform, Exclude is overloaded. When the first argument of Exclude is a multicast event and the second argument is an event handler, Include removes the event handler from the event's listeners.  

Delphi Examples: 

 

{
This example demonstrates the use of Include and Exclude routines.
The example assumes a form with three checkboxes and a button. Also
a field called FMsgButtons of type TMsgDlgButtons is declared in the form.
}
procedure TOptionsForm.btShowMessageClick(Sender: TObject);
begin
  //Creates a Message Dialog with the Selected Buttons
  MessageDlg('Hello World!', mtInformation, FMsgButtons, 0);
end;

procedure TOptionsForm.CheckBoxClick(Sender: TObject);
begin
  { Check wether an option is selected and add an element into a set,
    or exclude it from the set}

  if cbYes.Checked then
    Include(FMsgButtons, mbYes)
  else
    Exclude(FMsgButtons, mbYes);

  if cbNo.Checked then
    Include(FMsgButtons, mbNo)
  else
    Exclude(FMsgButtons, mbNo);

  if cbCancel.Checked then
    Include(FMsgButtons, mbCancel)
  else
    Exclude(FMsgButtons, mbCancel);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!