Delphi – E2034 Too many actual parameters

When a procedure or function call in your delphi program has more parameters than the procedure or function declaration allows, this error message appears.

Additionally, when an OLE automation call contains too many (more than 255) or too many named parameters, this error message appears.

program Produce;

function Max(A,B: Integer): Integer;
begin
  if A > B then Max := A else Max := B
end;

begin
  Writeln( Max(1,2,3) );   (*<-- Error message here*)
end.

Max would have found it more convenient if he could take three parameters…

program Solve;

function Max(const A: array of Integer): Integer;
var
  I: Integer;
begin
  Result := Low(Integer);
  for I := 0 to High(A) do
    if Result < A[I] then
      Result := A[I];
end;

begin
  Writeln( Max([1,2,3]) );
end.

Normally, you’d switch to call site to provide the correct number of parameters. We’ve chosen to demonstrate how to use Max with an infinite number of arguments. It’s worth noting that you’ll have to refer to it in a somewhat different way now.