Pregunta

As an exercise that put myself into, I wanted to design a calculator in Delphi. So, far the sum, subs tract, multiply and divided are pretty much working.

The only function that I have a problem with its with Square Root.

Variables are extended, and I pretty much just convert from String (I'm using two EditBox) to Float

var
   Form1: TForm1;
   a, b, r: Extended;

procedure TForm1.SqrtClick(Sender: TObject);
begin
   a  := StrToFloat(Edit1.Text);
   r  := Sqrt(a);
   ShowMessage(FloatToStr(r));
end;

Delphi its returning me

[Error] calc.dpr(72): Missing operator or semicolon.

¿Fue útil?

Solución

The problem isn't really visible in your snippet above. But since I got psychic powers, I can still tell what is going on here.

You have a button called sqrt on your form. Hence, when you write sqrt in code, it refers to the button, not to the RTL function.

Solution: Write System.Sqrt instead of Sqrt (=Self.Sqrt, the button), or rename the button.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top