Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Accessing the engine
Sun, Jul 26 2009 4:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

How do I access the engine when the datamodule on which its declared IS NOT in the unit I want to access it from?

Think of this scenario:

Create a general purpose component which will be used in several applications. This component will use ElevateDB and in it I want to check one or more of the engines properties (eg  UseLocalSessionEngineSettings) to decide on how the component should do something.

Obviously if I drop this component onto a form in several different apps it won't be accessing the same engine, in many cases the datamodule, and even the engine, will not have the same names (eg in one app the engine is TfREngine and in another MyMEngine).

So two questions really:

1. How do I detect if there is an engine component already there?
2. How do I access its properties?


Roy Lambert
Mon, Jul 27 2009 3:41 PMPermanent Link

"Jeff Cook"
Roy Lambert wrote:

<snip>
>
> 1. How do I detect if there is an engine component already there?
> 2. How do I access its properties?
>
>

Hi Roy

Definitely not an expert in component construction here ...

You could make the datamodule a property of your new component, then
you could find the engine component like this:-

 with datamodule do
 begin
   for i := 0 to ComponentCount - 1 do
   begin
     if (Components[i] is TEDBEngine)  then // or whatever it is called
     begin
       PropertyImLookingFor := (Components[i] as
TEDBEngine).ThisProperty;
       break;
     end;
   end;
 end;

?

--
Jeff Cook
Aspect Systems Ltd
www.aspect.co.nz
+
Joan and Jeff Cook
The Cooks Oasis
www.cookislandsoasis.com
Mon, Jul 27 2009 4:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< How do I access the engine when the datamodule on which its declared IS
NOT in the unit I want to access it from? >>

Use the global Engine() function in the edbcomps.pas unit.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jul 28 2009 2:33 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jeff


Good try but you missed the critical phrase "used in several applications" ie I'd need the datamodule from each app.

Roy Lambert
Tue, Jul 28 2009 2:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


I was hoping that would be the answer, but couldn't, and can't understand how Smiley

Roy Lambert
Image