Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#7

Re: Wieder ein Variablen Problem - komme nicht weiter.

  Alt 30. Sep 2008, 14:36
Und wie kannst du da erkennen, welches end zu welchem begin gehört?

Was ist besser lesbar? Deins:
Delphi-Quellcode:
procedure TForm1.Note;
var note, cache: Real;
begin
if (FiCountCorrect=0) and (jkeins=1) and (jkzwei=1) then
begin
note:=7;
end else if (FiCountCorrect=0) and (jkeins=1) then
         begin
         note:=65/10;
         end else if (FiCountCorrect=0) and (jkzwei=1) then
                  begin
                  note:=65/10;
                  end else if (FiCountCorrect=0) then
                           begin
                           note:=6;
                           end else if (jkeins=1) then
                                    begin
                                    note:=cache;
                                    note:=note+1/2;
                                    end else if (jkzwei=1) then
                                             begin
                                             note:=cache;
                                             note:=note+1/2;
                                             end else
                                                 begin
                                                 note:=cache;
                                                 note:=note-5/15;
                                                 end;
cache:=note;
Label7.Caption:=FloatToStr(RundeAufStelle(cache, 1));
end;
Oder meins:
Delphi-Quellcode:
procedure TForm1.Note;
var
  note, cache : Real;
begin
  if (FiCountCorrect = 0) and (jkeins = 1) and (jkzwei = 1) then
  begin
    note := 7;
  end
  else if (FiCountCorrect = 0) and (jkeins = 1) then
  begin
    note := 65 / 10;
  end
  else if (FiCountCorrect = 0) and (jkzwei = 1) then
  begin
    note := 65 / 10;
  end
  else if (FiCountCorrect = 0) then
  begin
    note := 6;
  end
  else if (jkeins = 1) then
  begin
    note := cache;
    note := note + 1 / 2;
  end
  else if (jkzwei = 1) then
  begin
    note := cache;
    note := note + 1 / 2;
  end
  else
  begin
    note := cache;
    note := note - 5 / 15;
  end;
  cache := note;
  Label7.Caption := FloatToStr(RundeAufStelle(cache, 1));
end;
Und dann sieht man auf den ersten Blick den Grund der Warnung.
Michael
  Mit Zitat antworten Zitat