Name
Write Directive
Syntax
propertyName:Type... writeSetter;
Description
A property’s write directive tells Delphi
how to change the property’s value. The
Setter can be the a field reference or a
method name in the class or in an ancestor
class.
If the Setter is a field, the
field’s type must be the same as the property’s type. The
usual access rules apply, so the field cannot be a private field of
an ancestor class unless the ancestor class is in the same unit.
Typically, the field is a private field of the same class that
declares the
property.
The field can be an aggregate (record or array), and the
Setter must specify a record member or
array element (at a constant index) of the appropriate type. Records
and arrays can be nested.
If the Setter is a method, the method must
be a procedure whose argument type is the same as the property type.
The method can be static or virtual, but it cannot be a dynamic
method or message
handler.
If the property is indexed or an array property, the
Setter must be a method. The first
parameter is the index value, which is an Integer.
Subsequent arguments are the array indices. The type of each
Setter argument must match the type of the
corresponding array index. The last argument is the new property
value.
When the user assigns to the property value, Delphi assigns the value
to the Setter field or calls the
Setter method.
Tips and Tricks
If you use a
Setterfield, Delphi compiles all property references into direct field references, so there is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access