要对每一位赋值。
解决方案 »
- 获得鼠标下所有的窗口句柄?windowfrompos只能一个?!!
- DateTimePicker 的问题
- 串口oncomm 事件问题
- 请问如何将容器groupbox内的所有包含对象清除 用什么方法或函数
- 软件发布:asf制作专家
- 请教加快delphi6下的TIdTcpServer通信速度问题?
- 请高手帮忙,非常急
- ???如何刷新FileListBox的内容,我用FileListBox.Refresh怎么没反应啊???
- 大家说的数据库SQLSERVER是怎么与DELPHI连接的啊!
- 哪位有QuickReport 3.5 Professional for Delphi 5 ????50分相送!!!!
- 100求Linux2001的ADSL计时器源代码
- 简单问题,在线等……
T: TBits;
begin
T := TBits.Create;
T.Size := 8;
T.Bits[0] := true;
T.Bits[1] := false;
...
end;
type
Bits = (bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7) ;
TSetBits = set of Bits ;
PsetBits =^TSetBits ;
const
Const_Bits : array[0..7] of Bits =(bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7) ;
var
P :PsetBits ;
begin
Result := (pos>=0) and (pos<=7) ;
if not Result then Exit ;
P :=@aByte ;
if boo then
Include(P^,Const_Bits[pos])
else
Exclude(P^,Const_Bits[pos]);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a : Byte ;
begin
a :=0;
SetValue(a,2,True) ;
caption := inttostr(a);
end;
result :=(((1 shl index)and value)<>0);或使用TBits类。
TBit = 0..1;// 位读
function GetBit(AValue: Byte; AIndex: 0..7): TBit;
const
Bool_Bit: array[False..True] of TBit = (0, 1);
begin
result := Bool_Bit[AValue and (1 shl AIndex)];
end;// 位写
procedure SetBit(var AValue: Byte; AIndex: 0..7; ABit: TBit);
begin
if ABit = 0 then
AValue := AValue xor (1 shl AIndex)
else
AValue := AValue or (1 shl AIndex);
end;
TBit = 0..1;// 位读
function GetBit(AValue: Byte; AIndex: 0..7): TBit;
const
Bool_Bit: array[False..True] of TBit = (0, 1);
begin
result := Bool_Bit[AValue and (1 shl AIndex) <> 0];
end;// 位写
procedure SetBit(var AValue: Byte; AIndex: 0..7; ABit: TBit);
begin
if ABit = 0 then
AValue := AValue xor (1 shl AIndex)
else
AValue := AValue or (1 shl AIndex);
end;
procedure SetBit(var AValue: Byte; AIndex: 0..7; ABit: TBit);
begin
if ABit = 0 then
AValue := AValue and not (1 shl AIndex)
else
AValue := AValue or (1 shl AIndex);
end;
procedure NotBit(var AValue: Byte; AIndex: 0..7);
begin
AValue := AValue xor (1 shl AIndex);
end;