Delphi Compiler Error
E2025 Procedure cannot have a result type
Reason for the Error & Solution
You have declared a procedure, but given it a result type. Either you really meant to declare a function, or you should delete the result type.
program Produce;
procedure DotProduct(const A,B: array of Double): Double;
var
I: Integer;
begin
Result := 0.0;
for I := 0 to High(A) do
Result := Result + A[I]*B[I];
end;
const
C: array [1..3] of Double = (1,2,3);
begin
Writeln( DotProduct(C,C) );
end.
Here DotProduct was really meant to be a function, we just happened to use the wrong keyword…
program Solve;
function DotProduct(const A,B: array of Double): Double;
var
I: Integer;
begin
Result := 0.0;
for I := 0 to High(A) do
Result := Result + A[I]*B[I];
end;
const
C: array [1..3] of Double = (1,2,3);
begin
Writeln( DotProduct(C,C) );
end.
Just make sure you specify a result type when you declare a function, and no result type when you declare a procedure.