RAD Studio Athens

E2034

Go Up to Error and Warning Messages (Delphi)

This error message occurs when a procedure or function call gives more parameters than the procedure or function declaration specifies.

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


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.

It would have been convenient for Max to accept 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 would change to call site to supply the right number of parameters. Here, we have chose to show you how to implement Max with an unlimited number of arguments. Note that now you have to call it in a slightly different way.