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.
Pascal
x
10
10
1
program Produce;
2
3
function Max(A,B: Integer): Integer;
4
begin
5
if A > B then Max := A else Max := B
6
end;
7
8
begin
9
Writeln( Max(1,2,3) ); (*<-- Error message here*)
10
end.
Max would have found it more convenient if he could take three parameters…
Pascal
xxxxxxxxxx
1
15
15
1
program Solve;
2
3
function Max(const A: array of Integer): Integer;
4
var
5
I: Integer;
6
begin
7
Result := Low(Integer);
8
for I := 0 to High(A) do
9
if Result < A[I] then
10
Result := A[I];
11
end;
12
13
begin
14
Writeln( Max([1,2,3]) );
15
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.
Leave Your Comment