RAD Studio Athens

E2130

Go Up to Error and Warning Messages (Delphi)

The property from which you are attempting to read a value did not specify a 'read' clause, thereby causing it to be a write-only property.


program Produce;

  type
    Base = class
      sย : String;

      property Passwordย : String write s;
    end;

  var
    cย : Base;
    sย : String;

begin
  sย := c.Password;
end.

Since c.Password has not specified a read clause, it is not possible to read its value.


program Solve;

  type
    Base = class
      sย : String;

      property Passwordย : String read s write s;
    end;

  var
    cย : Base;
    sย : String;

begin
  sย := c.Password;
end.

One easy solution to this problem, if you have source code, would be to add a read clause to the write-only property. But, adding a read clause is not always desirable and could lead to holes in a security system. Consider, for example, a write-only property called 'Password', as in this example: you certainly wouldn't want to casually allow programs using this class to read the stored password. If a property was created as write-only, there is probably a good reason for it and you should reexamine why you need to read this property.