2. Missing operator or semicolon

Pôvodný zdrojový kód

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
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, S, V: real;
begin

a:= StrToFloat(Edit1.Text);
b:= StrToFloat(Edit2.Text);
c:= StrToFloat(Edit3.Text);

V:= a*b*c;
S:= 2(a*b + a*c + b*c);

Label1.Caption:= 'V = ' + FloatToStr(V);
Label2.Caption:= 'S = ' + FloatToStr(S);

end;

{

[Error] Unit1.pas(40): Missing operator or semicolon
--------------------------------------------------------------------------------

Chýba operátor alebo bodkočiarka.

PREČO?

Na označenom mieste chýba operátor násobenia.

RIEŠENIE

Symbol * do výrazu dopíšeme.

Upravený zdrojový kód

--------------------------------------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);
var a, b, c, S, V: real;
begin

a:= StrToFloat(Edit1.Text);
b:= StrToFloat(Edit2.Text);
c:= StrToFloat(Edit3.Text);

V:= a*b*c;
S:= 2*(a*b + a*c + b*c);

Label1.Caption:= 'V = ' + FloatToStr(V);
Label2.Caption:= 'S = ' + FloatToStr(S);

end;

--------------------------------------------------------------------------------

}
end.

Stiahnuť vzorový príklad (zdrojové kódy v Delphi)