Delphi Compiler Error
E2239 Default parameter ‘%s’ must be by-value or const
Reason for the Error & Solution
Parameters which are given default values cannot be passed by reference.
program Produce; procedure p0(var x : Integer = 151); begin end; begin end.
Since the parameter x is passed by reference in this example, it cannot be given a default value.
program Solve; procedure p0(const x : Integer = 151); begin end; begin end.
In this solution, the by-reference parameter has been changed into a const parameter. Alternatively it could have been changed into a by-value parameter or the default value could have been removed.