help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'System' (#rtl)

Exclude

Exlude element from a set if it is present.

Declaration

Source position: system.fpd line 28

procedure Exclude(

  var S: TSetType;

  E: TSetElement

);

Description

Exclude removes E from the set S if it is included inthe set. E should be of the same type as the base type of the set S.

Thus, the two following statements do the same thing:

S:=S-[E];
Exclude(S,E);

Errors

If the type of the element E is not equal to the base type of the set S, the compiler will generate an error.

See also

Include

  

Include element in set if it was not yet present.

Example

program Example111;

{ Program to demonstrate the Include/Exclude functions }

Type
  TEnumA = (aOne,aTwo,aThree);
  TEnumAs = Set of TEnumA;

Var
  SA : TEnumAs;

  Procedure PrintSet(S : TEnumAs);

  var
    B : Boolean;

    procedure DoEl(A : TEnumA; Desc : String);

    begin
      If A in S then
        begin
        If B then
          Write(',');
        B:=True;
        Write(Desc);
        end;
    end;

  begin
    Write('[');
    B:=False;
    DoEl(aOne,'aOne');
    DoEl(aTwo,'aTwo');
    DoEl(aThree,'aThree');
    Writeln(']')
  end;

begin
  SA:=[];
  Include(SA,aOne);
  PrintSet(SA);
  Include(SA,aThree);
  PrintSet(SA);
  Exclude(SA,aOne);
  PrintSet(SA);
  Exclude(SA,aTwo);
  PrintSet(SA);
  Exclude(SA,aThree);
  PrintSet(SA);
end.
    

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505