function EncodeBools(bools : array of Boolean) : Integer;
var
i: Integer;
b : Boolean;
begin
Assert(High(bools) - Low(bools) <=32);
Result := 0;
for i := Low(bools) to High(bools) do
begin
b := bools;
Result := Result or (Integer(b) shl i);
end;
end;
function DecodeBools(Value : Integer
Index : Integer) : Boolean;
begin
Assert(Index < 32);
Result := Boolean((Value and (1 shl Index)) shr Index);
end;
procedure ShowBoolValue(b : Boolean);
begin
if b then ShowMessage('True') else ShowMessage('False');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
b1, b2, b3, b4, b5 : Boolean;
b6, b7, b8, b9, b10 : Boolean;
BoolsValue : Integer;
begin
b1 := False;
b2 := False;
b3 := True;
b4 := False;
b5 := True;
BoolsValue := EncodeBools([b1, b2, b3, b4, b5]);
//ShowMessage(IntToStr(BoolsValue));
b6 := DecodeBools(BoolsValue, 0);
b7 := DecodeBools(BoolsValue, 1);
b8 := DecodeBools(BoolsValue, 2);
b9 := DecodeBools(BoolsValue, 3);
b10 := DecodeBools(BoolsValue, 4);
ShowBoolValue(b6);
ShowBoolValue(b7);
ShowBoolValue(b8);
ShowBoolValue(b9);
ShowBoolValue(b10);
end;