Autor Beitrag
christian_m
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mo 28.05.07 10:01 
Hi Delphi-Community!

Ich möchte mit Hilfe von FindComponents 6 Shapes nach einem bestimmten Wert abfragen.
Die Shapes heißen Shape1, Shape 2 ... Shape 7. Nun möchte ich nicht alle abfragen, sondern nur die ersten zwei und dann das vierte bis zum siebten.

Kann ich das folgendermaßen machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
//Pseudocode 

 for y:= 1 to 2 and for y:= 4 to 7 do
  begin
    {Anweisung1}
    break
  end;



Oder muss ich für jede Schleife die (gleiche) Anweisung neu schreiben?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
//Pseudocode
 
 for y:= 1 to 2 do 
  begin
   {Anweisung1}
   break
  end;

  for y:= 4 to 7 do 
   begin
    {Anweisung1}
     break
   end;



Kann mir jemand einen Tipp geben wie das funktioniert?

mfg Chris
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Mo 28.05.07 10:15 
Deine erste Lösung mit dem and kann nicht funktionierten. Du musst dich hald an die richtige Syntax halten!

Also nimm zwei schleifen oder mach es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
for n := 1 to 7 do
begin
  if (n <= 2) or (n >= 4) then
    //Anweisung wird nur bei n = 1,2,4,5,6,7 ausgeführt
  //wieso Break? Break heißt Schleife verlassen.
end;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 28.05.07 10:18 
afaik gibts bei den neuen Delphi-Versionen auch eine for-Each-Schleife oder so. Da müsste das dann in etwa so gehen for each i in [1,2,4..7] do ... Aber die genaue Syntax kenne ich nicht, da ich meistens mit D7 arbeite, und da gibts das noch nicht ;-)

_________________
We are, we were and will not be.
christian_m Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mo 28.05.07 10:28 
Das ging ja schnell. :D
Danke für die Antworten !


Edit// PS Ich hab nur Delphi ver 4 :cry:

Gruß Chris