Einzelnen Beitrag anzeigen

Chris211183

Registriert seit: 19. Sep 2013
Ort: Braunschweig
204 Beiträge
 
Delphi 6 Professional
 
#1

Variable "P" ist möglicherweise nicht initialisiert worden

  Alt 24. Mär 2015, 09:25
Hallo,

finde den Fehler nicht, warum soll P nicht initialisiert sein ?






Delphi-Quellcode:
 Function mysin(const X: Extended):Extended; // Wrapper-Funktion, benötigt für Delphi 6 um Sinus-Funktion implementieren zu können
begin
   Result := sin(x);
end;



function THixHistoGraph.CalculatePointView // Berechnung der Punkte für die Funktionsdarstellung
(AFunc: TFxFunction; const HistoBackround: TRect; x0, y0, dx, dy: Extended): TPointDynArray;
var
  x, y: Extended;
  i : integer;
begin // für jede Spalte einen Punkt
   SetLength(Result, HistoBackround.Right - HistoBackround.Left + 1); // Punkte berechnen
   x := 0;
   for i := Low(Result) to High(Result) do
   begin
   y := AFunc(x);
   y := -y; // Canvas Nullpunkt obere linke Ecke mit Y- Achse nach unten !!!
   y := y0 + y; // oberen Rand Addieren
   y := y / dy; // Skalieren
   Result[i].x := HistoBackround.Left + i;
   Result[i].Y := HistoBackround.Top + Round(y); // runden
   x := x + dx;
   end; // nächster Punkt

end;


procedure THixHistoGraph.DrawComponent;
var
   ComponentBackround : TRect; // zeichnet Komponente
   HistoBackround : TRect; // zeichnet die Darstellungsfläche der Komponente
begin

 if FBorderstyle = bsSingle then // mit 3D-Rahmen

   begin
   inherited;
   if (Parent = NIL) or not visible
   then Exit;
   begin
   ComponentBackround := Rect(0, 0, Width, Height); // Koponentenhintergrund
   Canvas.Brush.Color := FColor;
   Canvas.Pen.Color := FColor;
   Canvas.Pen.Style := psSolid;
   Canvas.FillRect(ComponentBackround);
   Frame3D(Canvas, ComponentBackround, clBtnHighlight, clBtnShadow, 1); // 3D Rahmen mit der Breite von 1 für Komponentenhintergrund
   end;

      begin
      HistoBackround := Rect(FGapLeft, // Hintergrund der Darstellungsfläche
                              FGapTop,
                              Width - FGapRight,
                              Height - FGapBottom + 2);

      Canvas.Brush.Color := FHistoBkColor;
      Canvas.Pen.Color := FHistoBkColor;
      Canvas.FillRect(HistoBackround);
      Frame3D(Canvas, HistoBackround, clBtnShadow, clBtnHighlight, 1);
      DrawGrid;
      end;
   end;
end;


procedure THixHistoGraph.DrawMeasureValue; // Soll die Werte Zeichnen, die er von extern bekommt
var
  x0, y0, dy, dx : Real;
  i : Integer;
  P : TPointDynArray;
  HistoBackround : TRect;


begin
   HistoBackround := Rect(FGapLeft, // Hintergrund der Darstellungsfläche
                           FGapTop,
                           Width - FGapRight,
                           Height - FGapBottom + 2);

   InflateRect(HistoBackround, -1, -1);
   for i:= round(ViewXNominalMin) to round(ViewXNominalMax - 1) do
   begin
      ViewXNominalMin := FViewXNominalMin;
      ViewXNominalMax := FViewXNominalMax;
      x0 := FViewxNominalMin;
      y0 := (Height - FGapBottom - FGapTop) / FYScale.ValMax;
      dx := 0.05;
      dy := 0.02;
      P := CalculatePointView(mySin, HistoBackround, x0, y0, dx, dy);
      Canvas.Pen.Style := psSolid;
      Canvas.Brush.Color := clLime;
      Canvas.Pen.Color := clLime;
      DrawPointView(Canvas, HistoBackround, P); //HIER DIE FEHLERMELDUNG
   end;
end;
Christian
  Mit Zitat antworten Zitat