Thema: Delphi Befehl kürzen

Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: Befehl kürzen

  Alt 10. Feb 2008, 21:45
Wenn man sich mal die Mühe macht und diese Textwüste ordentlich einrückt...

Delphi-Quellcode:
if (gb19.Caption = Fahrzeug1.fkennung)
   and ( (btbg19.Caption <> '4')
        or (falscherstatus = false)
        or (btbg19.Caption <> '6')
        or (btbg19.Caption <> '7')
        or (btbg19.Caption <> '8')
        or (btbg19.Caption <> '3') ) then
begin
  btbg19.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg19.Caption = '1') or (btbg19.Caption = '2') or (btbg19.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb19.Caption = Fahrzeug2.fkennung)
   and ( (btbg19.Caption <> '4')
        or (falscherstatus = false)
        or (btbg19.Caption <> '6')
        or (btbg19.Caption <> '7')
        or (btbg19.Caption <> '8')
        or (btbg19.Caption <> '3') ) then
begin
  btbg19.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg19.Caption = '1') or (btbg19.Caption = '2') or (btbg19.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb19.Caption = Fahrzeug3.fkennung)
   and ( (btbg19.Caption <> '4')
        or (falscherstatus = false)
        or (btbg19.Caption <> '6')
        or (btbg19.Caption <> '7')
        or (btbg19.Caption <> '8')
        or (btbg19.Caption <> '3') ) then
begin
  btbg19.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg19.Caption = '1') or (btbg19.Caption = '2') or (btbg19.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb19.Caption = Fahrzeug4.fkennung)
   and ( (btbg19.Caption <> '4')
        or (falscherstatus = false)
        or (btbg19.Caption <> '6')
        or (btbg19.Caption <> '7')
        or (btbg19.Caption <> '8')
        or (btbg19.Caption <> '3') ) then
begin
  btbg19.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg19.Caption = '1') or (btbg19.Caption = '2') or (btbg19.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb20.Caption = Fahrzeug1.fkennung)
   and ( (btbg20.Caption <> '4')
        or (falscherstatus = false)
        or (btbg20.Caption <> '6')
        or (btbg20.Caption <> '7')
        or (btbg20.Caption <> '8')
        or (btbg20.Caption <> '3') ) then
begin
  btbg20.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb20.Caption = Fahrzeug2.fkennung)
   and ( (btbg20.Caption <> '4')
        or (falscherstatus = false)
        or (btbg20.Caption <> '6')
        or (btbg20.Caption <> '7')
        or (btbg20.Caption <> '8')
        or (btbg20.Caption <> '3') ) then
begin
  btbg20.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb20.Caption = Fahrzeug3.fkennung)
    and ( (btbg20.Caption <> '4')
         or (falscherstatus = false)
         or (btbg20.Caption <> '6')
         or (btbg20.Caption <> '7')
         or (btbg20.Caption <> '8')
         or (btbg20.Caption <> '3') ) then
begin
  btbg20.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5') then
begin
  falscherstatus := true;
end;

if (gb20.Caption = Fahrzeug4.fkennung)
   and ( (btbg20.Caption <> '4')
        or (falscherstatus = false)
        or (btbg20.Caption <> '6')
        or (btbg20.Caption <> '7')
        or (btbg20.Caption <> '8')
        or (btbg20.Caption <> '3') ) then
begin
  btbg20.Caption := '3';
end
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5') then
begin
  falscherstatus := true;
end;
dann kann man vielleicht schon mehr erkennen.
Allerdings nur vielleicht, in Wirklichkeit wird einem dann erst das ganze schreckliche Ausmaß klar und man sollte sich diesem Code vermutlich doch nicht weiter annähren als, naja, sagen wir mal 1km.

Was mich besonders stutzig macht, sind diese komischen...
Delphi-Quellcode:
else if (gb20.Caption = Fahrzeug4.fkennung)
        and (btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5') then
AND- und OR-Verknüpfungen. Fehlt da nicht eventuell noch ein Klammerpaar?

Also so...
Delphi-Quellcode:
else if (gb20.Caption = Fahrzeug4.fkennung)
        and ((btbg20.Caption = '1') or (btbg20.Caption = '2') or (btbg20.Caption = '5')) then
?

Ich sehe da noch viel mehr Problemstellen, lass es aber jetzt mal dabei.
Sorry, aber da vergeht einem ja echt jeglicher Spass am Programmieren.

Traurige Grüsse
Thorsten
  Mit Zitat antworten Zitat