Einzelnen Beitrag anzeigen

Benutzerbild von MaBuSE
MaBuSE

Registriert seit: 23. Sep 2002
Ort: Frankfurt am Main (in der Nähe)
1.837 Beiträge
 
Delphi 10 Seattle Enterprise
 
#9

Re: Problem mit nem Quelltext!!!!!!

  Alt 2. Feb 2005, 11:05
Zitat von janiboy:
Ich hab ne Frage zum Quelltext...
Wo ist der Fehler???
Der zeigt immer denn selben fehler an....

nämlich:

[Hint] Unit1.pas(50): Value assigned to 'x2' never used
[Hint] Unit1.pas(49): Value assigned to 'x1' never used

...

Bitte um Hilfe....

was mache ich Falsch
Zuallererst mal Herzlich Willkommen in der Delphi Praxis.

Mich wundert es, dass sich der Quelltext ohne Fehler kompilieren lässt, da ein "end;" fehlt.

Die Antworten wurden ja oben schon gegeben.

Hier nochmal der komplette überarbeitete Quellcode (ungetestet):

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    aedit: TEdit;
    bedit: TEdit;
    cedit: TEdit;
    Button1: TButton;
    x1edit: TEdit;
    x2Edit: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations } 
  public
    { Public declarations } 
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm} 

procedure TForm1.Button1Click(Sender: TObject);
var
  a, b, c,
  p, q,
  x1, x2: Real;
begin
  a := StrToInt(aedit.Text);
  b := StrToInt(bedit.Text);
  c := StrToInt(cedit.Text);
  if a=1 then
  begin
    p := b;
    q := c;
  end
  else
  begin
    p := b/a;
    q := c/a;
    // Das folgende "end;" hat gefehlt
  end;

// Folgende 2 Zeilen haben keine Wirkung, da in dem If .. Else .. Konstrukt
// x1 und x2 überschrieben werden.
// x1 := -p/2+sqrt(sqr(p/2)-q);
// x2 := -p/2+sqrt(sqr(p/2)-q);

  if sqr(p/2)-q>0 then
  begin
    x1 := 0;
    x2 := 0;
  end
  else
  begin
    if sqr(p/2)-q=0 then
    begin
      x1 := -p/2;
      x2 := -p/2;
    end
    else
    begin
      x1 := 99;
      x2 := 99;
    end;
  end;

  x1edit.Text := FloatToStr(x1);
  x2edit.Text := FloatToStr(x2);
end;

end.
(°¿°) MaBuSE - proud to be a DP member
(°¿°) MaBuSE - proud to be a "Rüsselmops" ;-)
  Mit Zitat antworten Zitat