Re: Manipulate objects by reference



"Adam Sandler" <corn29@xxxxxxxxxx> wrote in message
news:1126719218.807807.34420@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[...]
> for i := 0 to pred(ComponentCount) do
> if Components[i] is TwwDBEdit then
> Components[i].DataSource := ds;
>
> Like you mentioned .Name is avalable to Components in this context but
> it isn't clear to me that even though Delphi knows I'm working with
> TwwDBEdit types, wht are some of those type's properties not
> available???

Delphi does *NOT* know that you are working with a TwwDBEdit. *You* do,
because you've just tested for it.

Components[i] returns a TComponent. Every time. To use it as a TWhatever,
you have to cast it. You test beforehand so that you know the cast is
safe. The compiler does not look at the meaning of the cast, and does not
remember anything about it.

Groetjes,
Maarten Wiltink


.