Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Variablen und Bit-Abfrage in Schleife zusammenfassen (https://www.delphipraxis.net/106568-variablen-und-bit-abfrage-schleife-zusammenfassen.html)

Helmi 12. Jan 2008 21:59


Variablen und Bit-Abfrage in Schleife zusammenfassen
 
Hallo,

ich bräucht Hilfe.

Ich hab eine Bit-Abfrage einer Byte-Variable auf ein Array:
Delphi-Quellcode:
  Shape_aktiv[1] := not (LED_Zustand and 1) > 0;
  Shape_aktiv[2] := not (LED_Zustand and 2) > 0;
  Shape_aktiv[3] := not (LED_Zustand and 4) > 0;
  Shape_aktiv[4] := not (LED_Zustand and 8) > 0;
  Shape_aktiv[5] := not (LED_Zustand and 16) > 0;
  Shape_aktiv[6] := not (LED_Zustand and 32) > 0;
Ich würd das gern in eine Schleife bringen.

Wie kann ich das in einer Schleife machen?

DeddyH 12. Jan 2008 22:04

Re: Variablen und Bit-Abfrage in Schleife zusammenfassen
 
Delphi-Quellcode:
for i := 0 to 5 do
  Shape_aktiv[Succ(i)] := not ((LED_Zustand and (1 shl i)) > 0);
Getippt und nicht getestet.

[edit] Fehlende Klammern ergänzt ;) [/edit]

Helmi 12. Jan 2008 22:12

Re: Variablen und Bit-Abfrage in Schleife zusammenfassen
 
Danke!

Hat funktioniert!


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:51 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