Quick start manual

7-22
Delphi Language Guide
Properties
Given the declaration above, if Rectangle is of type TRectangle, then
Rectangle.Right := Rectangle.Left + 100;
corresponds to
Rectangle.SetCoordinate(2, Rectangle.GetCoordinate(0) + 100);
Storage specifiers
The optional stored, default, and nodefault directives are called storage specifiers.
They have no effect on program behavior, but control whether or not to save the
values of published properties in form files.
The stored directive must be followed by True, False, the name of a Boolean field, or
the name of a parameterless method that returns a Boolean value. For example,
property Name: TComponentName read FName write SetName stored False;
If a property has no stored directive, it is treated as if stored True were specified.
The default directive must be followed by a constant of the same type as the
property. For example,
property Tag: Longint read FTag write FTag default 0;
To override an inherited default value without specifying a new one, use the
nodefault directive. The default and nodefault directives are supported only for
ordinal types and for set types, provided the upper and lower bounds of the set’s
base type have ordinal values between 0 and 31; if such a property is declared
without default or nodefault, it is treated as if nodefault were specified. For reals,
pointers, and strings, there is an implicit default value of 0, nil, and '' (the empty
string), respectively.
Note
You can’t use the ordinal value 2147483648 has a default value. This value is used
internally to represent nodefault.
When saving a component’s state, the storage specifiers of the component’s
published properties are checked. If a property’s current value is different from its
default value (or if there is no default value) and the stored specifier is True, then the
property’s value is saved. Otherwise, the property’s value is not saved.
Note
Property values are not automatically initialized to the default value. That is, the
default directive controls only when property values are saved to the form file, but
not the initial value of the property on a newly created instance.
Storage specifiers are not supported for array properties. The default directive has a
different meaning when used in an array property declaration. See “Array
properties” on page 7-20.