Autor Beitrag
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Di 24.05.05 16:46 
Hallo,

unter Delphi 2005 gibt es ja die neue For In do Schleife:

ausblenden Delphi-Quelltext
1:
2:
For a in b do
...


Solange a element von b ist soll der Code ausgeführt werden. Nun meine Frage: wie ist hier Element zu verstehen?

EDIT: IN der D-Hilfe konnte ich keine Erklärung finden.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.05.05 09:22 
Du kannst eine Variable vom Typ "set of ..." nehmen, bei der kann man dann automatisch alle enthaltenen Werte durchgehen.
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 25.05.05 10:13 
Wie meinen?
Die Schleife sollte grundsätzlich mit allem laufen.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mi 25.05.05 10:23 
Nicht grundsätzlich mit allem.
Delphi2005-Online-Hilfe:

Folgende Iterationsmuster werden erkannt:
  • for Element in ArrayAusdr do Anw;
  • for Element in StringExpr do Anw;
  • for Element in SetAusdr do Anw;
  • for Element in KollektionsAusdr do Anw;


Wenn du mit dem IE unterwegs bist, dürfte dieser Link dich direkt zur entsprechende Hilfe-Seite bringen:
ms-help://borland.bds3/bds3guide/html/DeclarationsAndStatements.htm

Gruß,
raziel

_________________
JSXGraph
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 25.05.05 10:24 
Ich meinte das als Beispiel :wink: , was anderes fällt mir jetzt nicht ein...
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 25.05.05 15:28 
Ich bin mit dem Firefox unterwegs.


Zitat:
Ich meinte das als Beispiel :wink: , was anderes fällt mir jetzt nicht ein...

Nur änedrt das an meiner Frage nichts, ich versteh das mit dem Elemnt nunmal net ganz und kann daher weiterführende Beispiele erst recht nicht nachvollziehen.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 25.05.05 15:34 
user profile iconFabian W. hat folgendes geschrieben:
ich versteh das mit dem Elemnt nunmal net ganz und kann daher weiterführende Beispiele erst recht nicht nachvollziehen.
Na, wenn Du zum Beispiel ein Array myArray : Array of Integer hast und es drei Zahlen enthält, dann sind die drei Zahlen Elemente dieses Arrays. Und wenn ich nun for myInt in myArray do verwende, dann nimmt myInt in jedem Schleifendurchlauf einen dieser Werte an.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 25.05.05 16:14 
Also wenn man folgendes hat:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
type TByteSet: set of 0..7
...
var ByteSet: TByteSet;
    GetByte: Byte;
    i: Byte;
begin
 GetByte:=200
 ByteSet:=TByteSet(GetByte); //200-->11001000-->[3, 6..7]
 for i in ByteSet do
  begin

  end;
...
end;


Durchläuft er die Schlife nur 3 mal, also mit den Wert(i): 3, 6 und 7?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 25.05.05 16:22 
user profile iconHeiko hat folgendes geschrieben:
Durchläuft er die Schlife nur 3 mal, also mit den Wert(i): 3, 6 und 7?
Richtig. (Hättest es doch einfach nur ausprobieren brauchen ;-))

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 25.05.05 16:24 
Ja, jetzt hab ich's auch gecheckt. Danke.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 25.05.05 16:25 
Ja schon (werde ich auch noch), wollte aber erstmal die ganzen e-mails vom DF durcharbeiten. Und ich wollte Zeit sparen in dme ich gleichmal nachfrage. Außerdem kann Fabian W. die Schleife dann an einem Beispiel nachvollziehen :wink: .
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mi 25.05.05 16:27 
Er denkt weiter... :wink: :D :mrgreen: