Autor Beitrag
majolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Di 15.10.02 19:37 
Hi eine Frag zu folgendem code:
ausblenden 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:
ausblenden 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
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Di 15.10.02 20:38 
probiers mal damit. Müsste eigentliche funktionieren, habe mich aber nicht wirklich mit deinem Prob beschäftigt :mrgreen:

ausblenden Quelltext
1:
2:
3:
4:
If ((i1=3) or (i1=4) or (i1=5)) and (i2=1) then 
   begin 
    Z1:='e'; 
   end;

_________________
Viele Grüße
Jakob
majolo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Di 15.10.02 21:27 
Hauptsache ein Denkanstoss. :wink: Werds gleich mal ausprobieren
Gruss
majolo
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Di 15.10.02 21:28 
jo, musst halt mal mit der klammersetzung ein bisschen rumspielen :wink:

_________________
Viele Grüße
Jakob
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: 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
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: 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



BeitragVerfasst: Di 15.10.02 21:44 
Ich kann immer nur von dem ausgehen, was ich sehe.
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Di 15.10.02 22:05 
habe dir ja auch nicht wiedersprochen :)

_________________
Viele Grüße
Jakob
Cashels
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167



BeitragVerfasst: Mi 16.10.02 09:51 
DeCodeGuru hat folgendes geschrieben:
:mrgreen:

ausblenden 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:
ausblenden 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: 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
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Mi 16.10.02 20:39 
EBEN!!!!!! :mrgreen: :mrgreen: