Subject Re: [IBO] How to send component name as parameter to access IBO component's methods
Author Helen Borrie
At 12:41 AM 01-06-01 -0700, you wrote:
>Thanks for the quick reply, your great!
>So what I gather from your pseudo code is that I still have to list a long series of
>components and the various methods that I want to access, one set for each component.
>It doesn't look like I can simply list :
><some component>.prepare;
><some component>.ParamByName('ClientID').AsInterger......(from your previous help)
><some component>.execute;

If they are all components of the same class, you can. Let's say they are all TIB_DSQL... then you can write a generic procedure that works for *any" object of that class. But you can't pass the component name as a string, you need to pass it as a member of that class. So, first declare and create a variable of that class (e.g. AStatement: TIB_DSQL), instantiate it (call its Create method), assign the appropriate component to it and pass it (AStatement) in your procedure call. Then your procedure just works on AStatement, which acts as a pointer to the component that was assigned to it.

Don't forget to destroy AStatement when you have finished with it. Do that in the method (handler) that creates it, i.e. as soon as you have created the object variable, open a try...finally loop. Put everything inside the try... block and put the .Free call for the variable in the ..Finally block.

Apologies to any space visitors out there who are trying to analyse human language from this email.


>where I change the <some component> based on what I pass to the procedure?
>What I'm trying to do here is save about 10 minutes of time by spending 2 hours of
>figuring out how to do it! <BG>
>Thanks again,
>Your use of Yahoo! Groups is subject to

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