AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Zugriff auf einzelne bits einer Variable
Thema durchsuchen
Ansicht
Themen-Optionen

Zugriff auf einzelne bits einer Variable

Ein Thema von earlyperl · begonnen am 15. Apr 2008 · letzter Beitrag vom 15. Apr 2008
 
Benutzerbild von nicodex
nicodex

Registriert seit: 2. Jan 2008
Ort: Darmstadt
286 Beiträge
 
Delphi 2007 Professional
 
#12

Re: Zugriff auf einzelne bits einer Variable

  Alt 15. Apr 2008, 11:30
Zitat von earlyperl:
Mein Gott ist das kompliziert...
Nö, nur anders

Zitat von earlyperl:
Ich habe Delphi 6 Pro.
Schade, in aktuellen Delphi-Versionen hätte man den Array-Operator für Bits (so wie im MC-Pascal) nachbilden können.

Zitat von earlyperl:
wenn du mir jetzt noch verrätst, wie ich ein bit setzen kann, währe ich dir sehr dankbar!
Include/Exclude für einzelne Bits, oder +/- für mehrere:
Delphi-Quellcode:
var
  Foo: TByteBits;
begin
  Foo := [bBit1, bBit3, bBit5];
  ShowMessage(IntToStr(Byte(Foo)));
  Include(Foo, bBit0);
  Include(Foo, bBit2);
  Exclude(Foo, bBit1);
  Exclude(Foo, bBit3);
  ShowMessage(IntToStr(Byte(Foo)));
  Foo := Foo - [bBit0, bBit2] + [bBit1, bBit3];
  ShowMessage(IntToStr(Byte(Foo)));
end;
ps: man kann auch ".." verwenden um Bit-Bereiche anzugeben: [bBit0..bBit3, bBit7] sind die ersten vier Bits und das höherwertigste Bit ($8F).
Nico Bendlin
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz