An object that can hold an infinite number of Boolean values Classes unit
  type TBits;
The TBits type holds a flexible collection of bits (Boolean values).
The colection size can be altered at any time (using the size property).
Bits are accessed using the Bits property, like this :
flag := myBits.Bits[2];
or, more simply:
flag := myBits[2];
There is one utility function - OpenBit - which returns the index of the first false value. There is no equivalent for true values.
Related commands
Array A data type holding indexable collections of data
Boolean Allows just True and False values
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : A simple example
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
  Classes,   // Unit containing the TBits command
  Forms, Dialogs;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
Form1: TForm1;
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);

  flags : TBits;         // Our variable collection of Boolean values
  i : Integer;
  // Create our TBits object
  flags := TBits.Create;

  // Add a few items to our Boolean flags collection
  flags.Size := 5;

  // And set a few values
  flags[0] := true;
  flags[1] := true;
  flags[4] := true;

  // Now display the contents of the collection
  // Note that indexing starts at 0
  for i := 0 to flags.Size-1 do
    if flags[i] = true
    then ShowMessageFmt('Bit %d is true',[i])
    else ShowMessageFmt('Bit %d is false',[i]);

  // TBits has one main method -
  // to find the index of the first false value
  ShowMessageFmt('Index of the first false value is %d',[flags.OpenBit]);
Hide full unit code
   Bit 0 is true
   Bit 1 is true
   Bit 2 is false
   Bit 3 is false
   Bit 4 is true
   Index of the first false value is 2
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page