On using the old method of property declaration as a Set part handler, a procedure is specified, which contains in its signature parameters passed by reference (with the Var keyword). Only procedures with parameters passed by value can be used as handlers.
Delete the Var keyword specified before the parameters in the header of the procedure used by the property.
Class MyClass: Object
Private PropValue: Array Of String;
Public Constructor Create(Length: Integer);
Begin
PropValue := New String[Length];
End Constructor Create;
Sub Set_Item(i: Integer; Var s: String);
Begin
PropValue[i] := s;
End Sub Set_Item;
Function Get_Item(i: Integer): String;
Begin
Return PropValue[i];
End Function Get_Item;
Public Property Item(i: Integer): String Get Get_Item Set Set_Item;
End Class MyClass;
When the specified code is compiled, the following error is displayed: The 'Set_Item' method cannot contain parameters passed by reference. To resolve the error, delete the Var keyword specified before the "s" parameter in the area of declaration of Set_Item procedure variables.
See also:
Compiler Messages | Error: Method that Implements Indexed Property cannot Contain Parameters Passed by Reference