![]() |
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:
Ich würd das gern in eine Schleife bringen.
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; Wie kann ich das in einer Schleife machen? |
Re: Variablen und Bit-Abfrage in Schleife zusammenfassen
Delphi-Quellcode:
Getippt und nicht getestet.
for i := 0 to 5 do
Shape_aktiv[Succ(i)] := not ((LED_Zustand and (1 shl i)) > 0); [edit] Fehlende Klammern ergänzt ;) [/edit] |
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