If you intend on adding more than two categories, in addition to Private and Test, then the following procedure is more logical:
type
TUseBits = bitpacked array[0..7] of boolean;
TBooleanTag = bitpacked record
case boolean of
true: (Val: PtrInt);
false: (Bit: TUseBits)
end;
procedure SetVisibleByTags_bitwise2(Parent: TWinControl; ControlTag: TBooleanTag);overload;
const mask=128+64;
var
C: TComponent;
aTag: TBooleanTag;
begin
for C in Parent do begin
if C.Tag<>0 then begin
aTag.Val := C.Tag and mask;
if C is TMenuItem then TMenuItem(C).Visible := (aTag.Val and ControlTag.Val) <> 0
else if C is TControl then TControl(C).Visible := (aTag.Val and ControlTag.Val) <> 0;
end;
end;
end;
But if you insist on using categories as parameters instead of one variable, then you need to use another overloaded version that has the signature you want:
procedure SetVisibleByTags_bitwise2(Parent: TWinControl; pPrivate, pTest:boolean);overload;
var
ControlTag: TBooleanTag;
begin
ControlTag.Val := 0; { Not needed, for 'mask' used in the next proc clears unused bits }
ControlTag.bit[7] := pPrivate; ControlTag.bit[6] := pTest;
SetVisibleByTags_bitwise2(Parent, ControlTag);
end;