Delphi Compiler Error
E2237 Parameter ‘%s’ not allowed here due to default value
Reason for the Error & Solution
When using default parameters a list of parameters followed by a type is not allowed; you must specify each variable and its default value individually.
program Produce; procedure p0(a, b : Integer = 151); begin end; begin end.
The procedure definitions shown above will cause this error since it declares two parameters with a default value.
program Solve; procedure p0(a : Integer; b : Integer = 151); begin end; procedure p1(a : Integer = 151; b : Integer = 151); begin end; begin end.
Depending on the desired result, there are different ways of approaching this problem. If only the last parameter is supposed to have the default value, then take the approach shown in the first example. If both parameters are supposed to have default values, then take the approach shown in the second example.