type TBit = 0..7; Function Contains(const Value : Byte; Bit : TBit) : Boolean; begin Result := (Value and (1 shl Bit)) <> 0; end;
Function BinToStr(const Value : Byte) : String; var i : Integer; begin Result := ''; for i := 7 downto 0 do if (Value and (1 shl i)) <> 0 then result := result + '1' else result := result + '0'; end;
type TBit = 0..7; Function Contains(const Value : Byte; Bit : TBit) : Boolean; begin Result := (Value and (1 shl Bit)) <> 0; end;
Function BinToStr(const Value : Byte) : String; var i : Integer; begin Result := ''; for i := 7 downto 0 do if (Value and (1 shl i)) <> 0 then result := result + '1' else result := result + '0'; end;
procedure TForm1.Button1Click(Sender: TObject); begin if Contains(2, Button1.Tag) then Caption := BinToStr(2); Button1.Tag := Button1.Tag +1; end;
var Fbit1, Fbit2, Fbit3, Fbit4, Fbit5, Fbit6, Fbit7, Fbit8: boolean;
procedure TForm1.Button1Click(Sender: TObject); var DataRead: Byte; Data: string; begin DataRead := PortIn($370); // Din function til læsning af bytes fra port Data := copy(inttobin(DataRead), length(inttobin(DataRead)) - 7, length(inttobin(DataRead)));
if Data[1] = '1' then FBit8 := true else FBit8 := false; if Data[2] = '1' then FBit7 := true else FBit7 := false; if Data[3] = '1' then FBit6 := true else FBit6 := false; if Data[4] = '1' then FBit5 := true else FBit5 := false; if Data[5] = '1' then FBit4 := true else FBit4 := false; if Data[6] = '1' then FBit3 := true else FBit3 := false; if Data[7] = '1' then FBit2 := true else FBit2 := false; if Data[8] = '1' then FBit1 := true else FBit1 := false; end;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.