![]() |
while not ... do
ich hab da ein kleines Anfängerproblem mit der
while not ... do - schleife entweder bin ich zu dumm, oder die Syntax von Delphi gefällt mir nicht ;)
Delphi-Quellcode:
das funktioniert nicht, wenn der operator='Sq' ist (und das ist er - das hab ich mit dem debugger geprüft).
while not (Tformelobjekt(formellist[i]).operator = '^') OR (Tformelobjekt(formellist[i]).operator = 'Sq')
do inc(i); kann man bei while keine mehreren bedingungen angeben!? muss ich das dann so machen?
Delphi-Quellcode:
oder halt in zwei schleifen nacheinander. das kann doch eigentlich nicht!?
while not (Tformelobjekt(formellist[i]).operator = '^') do
begin while not (Tformelobjekt(formellist[i]).operator = 'Sq') do inc(i); inc(i); end; also was mach ich falsch. |
Re: while not ... do
Wenn beide Abfragen nicht eintreffen dürfen, musst du 2x not schreiben, falls dies dein problem ist:
Delphi-Quellcode:
while not (Tformelobjekt(formellist[i]).operator = '^') OR not (Tformelobjekt(formellist[i]).operator = 'Sq')
do inc(i); |
Re: while not ... do
Mach es besser so:
Delphi-Quellcode:
while not ((Tformelobjekt(formellist[i]).operator = '^') OR (Tformelobjekt(formellist[i]).operator = 'Sq'))
do inc(i); |
Re: while not ... do
oh ich idiot :-D
danke vielmals, funktioniert perfekt. |
Re: while not ... do
Hi Matze,
ganz stimmt dies nicht. Laut Boolescher Algebra gilt: (not (A or B)) ist nicht ((not A) or (not B)), sondern ((not A) and (not B)). Ich hoffe das war halbwegs verständlich, denke es einfach mal mit 0 und 1 durch, dann wirst du sehn ;) Greetz alcaeus |
Re: while not ... do
Also war meines Syntaktisch korrekt?
Faszinerend... |
Re: while not ... do
Zitat:
Zitat:
1) !a or !b 2) !(a or b) Mal die 2 Wahrheitstafeln dazu (Ergebnis in Fett):
Code:
1) Wenn mindestens eine der Bedingungen false ist Ergebnis true
1)
!a [b]or[/b] !b 1 [b]1[/b] 1 1 [b]1[/b] 0 0 [b]1[/b] 1 0 [b]0[/b] 0 2) [b] [b]1[/b] 0 0 0 [b]0[/b] 0 1 1 [b]0[/b] 1 1 0 [b]0[/b] 1 1 1 2) Nur wenn beide Bedingungen nicht zutreffen ist Ergebnis true Ich denke Dax's Variante dürfte das gewollte machen :). \\edit: Alter Falter binnisch wieder laaahhhmmm :lol: |
Re: while not ... do
Zitat:
|
Re: while not ... do
ja, das ist mir schon klar. ;)
Er sagte aber: Zitat:
|
Re: while not ... do
Zitat:
ich hab deins genommen und funzt super. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:33 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