Autor |
Beitrag |
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 15.10.02 19:37
Hi eine Frag zu folgendem code:
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| If (i1=3) and (i2=1) then begin Z1:='e'; end;
If (i1=4) and (i2=1) then begin Z1:='e'; end;
If (i1=5) and (i2=1) then begin Z1:='e'; end; |
Ich möchte den Code eigentlich ein bisschen kürzen. Weil i2 hat bei mir ja bei jeder Definition den gleichen Wert.Nämlich 1.
Ich habe versucht es mit or zu verbinden.Klappte aber nicht.Also das Programm startete hatte aber nicht das von mir gewünschte Ergebnis.
Etwas so proggte ich das:
Quelltext 1: 2: 3: 4:
| If (i1=3) or (i1=4) or (i1=5) and (i2=1) then begin Z1:='e'; end; |
Kann mir einer helfen.
Gruss
majolo
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 15.10.02 20:38
_________________ Viele Grüße
Jakob
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 15.10.02 21:27
Hauptsache ein Denkanstoss. Werds gleich mal ausprobieren
Gruss
majolo
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 15.10.02 21:28
jo, musst halt mal mit der klammersetzung ein bisschen rumspielen
_________________ Viele Grüße
Jakob
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 15.10.02 21:34
Wenn i2 sowie so immer 1 ist, warum nimmst du es dann mit in die Abfrage rein? Es spielet doch gar keine Rolle? Oder habe ich da jetzt einen Denkfehler? Das Ergebnis hängt doch einzig und alleine von den anderen Variablen ab.
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 15.10.02 21:41
was ist aber, wenn seine Abfrage noch wesentlich länger ist und dass sich der andere Wert auch noch ändert. Gut aus dem Codeschnipsel, den er uns gab, konnte man das nicht herauslesen und wenn das die ganzen abfragen sind, dann hast du recht @Luckie
_________________ Viele Grüße
Jakob
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 15.10.02 21:44
Ich kann immer nur von dem ausgehen, was ich sehe.
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Di 15.10.02 22:05
habe dir ja auch nicht wiedersprochen
_________________ Viele Grüße
Jakob
|
|
Cashels
Beiträge: 167
|
Verfasst: Mi 16.10.02 09:51
DeCodeGuru hat folgendes geschrieben: |
Quelltext 1: 2: 3: 4:
| If ((i1=3) or (i1=4) or (i1=5)) and (i2=1) then begin Z1:='e'; end; | |
Noch bischen kürzer gehts, falls i1 <= 255: Quelltext 1: 2: 3:
| if (i1 in [3,4,5]) and (i2 = 1) then begin Z1 := 'e' ; end ; |
Ich find die Variante auf jedenfall einfacher zu lesen.
Gruss,
Tom
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Mi 16.10.02 18:35
hi, der Wert von i2 ändert sich.Soviel dazu.Sorry,bisschen ungenau gepostet.Diese Abfrage ist lediglich eine Ausnahme prüfung.Falls diese positiv ausfällt muss: Z1 den Wert e annehmen.Der Code hat übrigens funktioniert.
gruss
majolo
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Mi 16.10.02 18:49
Zitat: | Sorry,bisschen ungenau gepostet |
Hat ja gereicht, dass wir dir helfen konnten.
Zitat: | Der Code hat übrigens funktioniert. |
Das ist ja das Wichtigste.
_________________ Viele Grüße
Jakob
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Mi 16.10.02 20:39
EBEN!!!!!!
|
|