Name

Exclude Procedure

Syntax

procedure Exclude(var ASet: Set type; Value: Ordinal type);

Description

The Exclude procedure removes the element Value from the set variable ASet. The type of Value must be the base type of ASet. Exclude is not a real procedure.

Tips and Tricks

Note that you cannot use a property for the set reference because a property value cannot be used as a var parameter. Instead, use the - operator to remove the member from the set, as shown below:

Font.Style := Font.Style - [fsBold];

Example

// The TFontStyleProperty editor toggles the bold font style when
// the user double-clicks the TFont.Style property in the
// object inspector.
type
  TFontStyleProperty = class(TSetProperty)
  public
    procedure Edit; override;
  end;
...
procedure TFontStyleProperty.Edit;
var
  Style: TFontStyles;
begin
  Style := TFontStyles(Byte(GetOrdValue));// Get the current font style.
  if fsBold in Style then
    Exclude(Style, fsBold)
  else
    Include(Style, fsBold);
  SetOrdValue(Byte(Style));           // Set the component's font style.
end;

See Also

In Keyword, Include Procedure, Set Keyword

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.