Autor Beitrag
´|` R /\ I | ) O $
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: Fr 18.04.08 23:06 
Hi, ne kurze Frage:

Gibts ne Möglchkeit bei der repeat-until-Schleife ne Mehrfache Bedingung am Ende zu machen?
Bsp.:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
repeat
a:=X+1 ( oder sonst was )
until
b:=b+b or showmessage('Hallo');


Also im Prinzip: Dass ich durch "or" oder "and" ect. Dinge verbinden kann, und das ich z.B. sowas wie "b:=b+b" und "Showmessage('Hallo');" zusammen als Bedingung nehmen kann?


Moderiert von user profile iconNarses: Topic aus VCL (Visual Component Library) verschoben am Sa 19.04.2008 um 01:31

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 18.04.08 23:12 
Hinter "until" schreibt man normalerweise eine Bedingung, wann die Schleife abgebrochen werden soll, also z.B. sowas wie a = 10 oder so.
Da kann keine Zuweisung oder Prozedur stehen.
Stell dir das wie eine If-Abfrage vor.

Du schreibst ja auch nicht
ausblenden Delphi-Quelltext
1:
if b := b + b  then ...					

das funktioniert ja auch nicht.

Edit: Und um deine Frage zu beantworten, ja, man kann die Bedingungen kombinieren, z.B.
ausblenden Delphi-Quelltext
1:
2:
3:
repeat
...
until (a=10)  or  (b=5)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 18.04.08 23:24 
Die Bedingung in der repeat-until-Schleife ist ein Boolscher Ausdruck. Was da möglich ist, kannst Du z.B. hier nachsehen (ein bisschen nach unten scrollen, dann kommt das).

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
´|` R /\ I | ) O $ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: So 20.04.08 17:04 
Also müsste ich theoretisch showmessage in Boolean umwandeln, damit ich es nehmen kann?
Wenn ja, kann mir jmd. sagen, wie ich das machen kann?

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
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: So 20.04.08 17:10 
Das geht gar nicht, und macht auch keinerlei Sinn. Was willst du denn damit bezwecken?

_________________
We are, we were and will not be.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 20.04.08 17:14 
Hi,

Du meinst wahrscheinlich, dass die Schleife so lange laufen muss, bis die entsprechende Nachricht angezeigt wird. Das ist so relativ schwer zu bewerkstelligen. Am besten, du setzt einfach eine der anderen Abbruchbedingungen so, dass aus der Schleife ausgestiegen wird, wenn du die Message zeigst.

Am besten ist es aber wirklich, du schaust dir den Crashkurs mal an.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
´|` R /\ I | ) O $ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: So 20.04.08 17:18 
Naja, das is ja genau das. Wenn die Message kommt, oder die andere Bedingung, dann soll Abbruch kommen. Das is ja im Prinzip schon die Anzeige der Message.

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
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: So 20.04.08 17:21 
Das macht doch keinen Sinn. Sprachlich wäre das etwas wie "Fahre so lange weiter bis Frage nach dem Weg". ShowMessage ist eine Aktion, keine Bedingung, die wahr oder falsch sein kann.

_________________
We are, we were and will not be.
´|` R /\ I | ) O $ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: So 20.04.08 17:25 
Richtig! Genau das ist ja mein Problem. . . .
Ich hab schon überlegt, ob ich aus der Showmessage ne procedure mache und die dann aufrufen kann, wäre das möglich ( rein vom logischen her, wenn showmessage nicht geht )?

Edit: Das Einzige, woran bis jetzt gescheitert ist, dass ich das probiere ist, dass ich für ne procedure ja ne Variable brauche.

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
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: So 20.04.08 17:29 
Ein Prozedur ist auch eine Aktion. Du könntest höchstens eine Funktion schreiben, die einen Booleanwert zurückliefert.

Nebenbei...hast du dir mal einen Crashkurs oder so angeschaut, durchgearbeitet und vor allem verstanden was da beschrieben wird?

_________________
We are, we were and will not be.
´|` R /\ I | ) O $ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: So 20.04.08 17:33 
Ja, ja und ja. Deswegen hab ich gefragt, wie ich das genau umsetzen kann.

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
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: So 20.04.08 17:37 
Was umsetzen? Wie man mehrere Bedingungen verknüpft, wurde in der ersten Antwort schon beschrieben.

_________________
We are, we were and will not be.
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: So 20.04.08 17:38 
du könntest an dem Punkt, an dem du Showmessage aufrufst eine Boolesche Variable nutzen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
begin
  showmessage('Deine Message');
  MeinBool := True;
end;


und dann wenn du abfragst:
ein weitere Boolean ^^

ausblenden Delphi-Quelltext
1:
2:
if (Bedingung) or (MeinBool) then 
  SchleifenEndeBool := True;


und dann die schleife mit dem SchleifenEndeBool anhalten.

PS:
Ich weiß es ist umständlich, aber ich glaube es klappt.
´|` R /\ I | ) O $ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 62



BeitragVerfasst: So 20.04.08 17:53 
Geht nich. Er sagt mir, dass die Operation auf diesen OP-Typ nicht anwendbar sind.

_________________
Manche behaupten Delphi sei nicht "mächtig" genug.
Ich sage: Mir doch egal! Ich mag es! Ich nutze es!
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: So 20.04.08 17:56 
So, ich mach hier mal ein paar Stündchen zu.

Du setzt dich jetzt hin, und gehst nochmal die Grundlagen durch, dann sehen wir hier weiter.

[Edit: Wieder offen]

_________________
We are, we were and will not be.