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
>(findcomponent(ParameterStringNameofComponent)).prepare;
>
>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)
...
var
ii: integer;
cName: string;

...
begin
for ii := 0 to ComponentCount - 1 do
begin
cName := Components[ii].Name;
if (cName = 'Something' )
or (cName = 'Something1')
or (....) then
begin
....
end
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>

or

if Something is TIB_Datapump then
TIB_Datapump(Something).xxxxxxxx

Hope this isn't too obscure!

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________