Subject Re: [IBO] How to send component name as parameter to access IBO component's methods
Author Helen Borrie
At 12:01 AM 01-06-01 -0700, you wrote:
>Hi, All:
>New to Delphi and IBO, but could use some help.
>Trying to write a procedure which I can pass as a string the component
>handler name, so that I can prepare/execute a series of datapump
>component groups (i.e. IB_Cursor, IB_datapump, IB_dsql), one group for
>each of about 7 tables that I need to archive records, then delete.
>Another Delphi programmer suggested using FindComponent(), but it just
>doesn't quite work as in:
>with dmPVEditor do
>I get an "undeclared identifier" error.
>Maybe I'm going about this all wrong, but there seems that there should
>be a way to do this.

Use the Components[] Array of your container (form, datamodule)
ii: integer;
cName: string;

for ii := 0 to ComponentCount - 1 do
cName := Components[ii].Name;
if (cName = 'Something' )
or (cName = 'Something1')
or (....) then
else if ....

...and so on...

You might like/need to make use of object casting, using

with Something as TIB_Datapump do
<anything that Something can do if it is of the TIB_Datapump class or a descendant>


if Something is TIB_Datapump then

Hope this isn't too obscure!


All for Open and Open for All
InterBase Developer Initiative ยท