tags:

views:

327

answers:

2

Delphi allows a stored keyword when defining properties as follows:

property Fields: TIndexDefs read FFields write SetFields stored FieldsStored;

What is the purpose of the keyword and what does it do?

+10  A: 

From my Delphi 7 help file:

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.

This sounds like it controls whether or not to store a property relating to a component in the .DFM file for the form. (Just a guess though)

cmw
Your guess is right. :-) However it works for **all** components, not only visual controls.
Ulrich Gerhardt
Change "visual control" to "component", and I'll upvote this answer. :-)
Ken White
"Sounds like"? Cmw, that's *exactly* what the documentation says in the first paragraph you quoted. No need to guess.
Rob Kennedy
@Ken: changed =]@Rob: Yes that's exactly what it _says_ but I didn't test what it actually _does_.
cmw
+3  A: 

This keyword determines if a property value should be saved in a form file; it is true by default. It can be useful to avoid, for example, saving big chunks of binary information in your .dfm file (for example, an image component that must read its contents at runtime only.)

Leonardo Herrera