Einzelnen Beitrag anzeigen

AlexII

Registriert seit: 28. Apr 2008
1.717 Beiträge
 
FreePascal / Lazarus
 
#1

Wieder ein Variablen Problem - komme nicht weiter.

  Alt 30. Sep 2008, 13:19
Hallo, muss erst mal sagen, dass bis Gestern nie Probleme oder Fehler mit Variablen hatte, aber seit Gestern schon das zweite und zwar:

Habe bis jetzt diesen Code gehabt:

Delphi-Quellcode:
function RundeAufStelle(zahl: double; stellen: integer): double;
var multi: double;
begin
  multi:=IntPower(10, stellen);
  zahl:=round(zahl*multi);
  result:=zahl/multi;
end;

procedure TForm1.Note;
var note: 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:=StrToFloat(Label3.Caption);
                                    note:=note+1/2;
                                    end else if (jkzwei=1) then
                                             begin
                                             note:=StrToFloat(Label3.Caption);
                                             note:=note+1/2;
                                             end else
                                                 begin
                                                 note:=StrToFloat(Label3.Caption);
                                                 note:=note-5/15;
                                                 end;
Label3.Caption:=FloatToStr(note);
Label7.Caption:=FloatToStr(RundeAufStelle(StrToFloat(Label3.Caption), 1));
end;
und hab diesen etwas auf diese Version geändert, aber der spinnt jetzt auf ein mal und ich bekomme eine Warnung "[Warnung] MAIN.pas(134): Variable 'cache' ist möglicherweise nicht initialisiert worden" Weiß nicht wo der Fehler liegt.

Delphi-Quellcode:
function RundeAufStelle(zahl: double; stellen: integer): double;
var multi: double;
begin
  multi:=IntPower(10, stellen);
  zahl:=round(zahl*multi);
  result:=zahl/multi;
end;

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;
  Mit Zitat antworten Zitat