[Gambas-user] gambas and components

Charlie Reinl Karl.Reinl at ...2345...
Mon Mar 19 15:53:43 CET 2012


Am Montag, den 19.03.2012, 22:49 +1030 schrieb Bruce Bruen:
> On Mon, 2012-03-19 at 22:42 +1030, GMail wrote:
> > On Mon, 2012-03-19 at 11:43 +0100, Karl Reinl wrote:
> > > Salut,
> > > 
> > > my question is for gambas2 and later for gambas3 
> > > 
> > > I have an app, which uses gambas (home made) components.
> > > 
> > > What does these components know about the app.
> > > 
> > > What I'm looking for is, how can I call a Function in the app, 
> > > out from the component, to report what has be done.
> > > 
> > > If I try 'Form.Function()', I get 'unknown Symbol' error
> > > 
> > > I know I can use the disk for passing something backwards, but I would
> > > first ask if there is a way.
> > Karl, 
> > I don't know whether this will help in your case but there is a way to
> > do this ... for examples where the component class is inherited by an
> > application class.
> > 
> > Due to the virtual dispatch used by gambas, the actual method called
> > will be the inherited method.
> > 
> > So (for general readers) if you consider a component containing a base
> > class "Fred" that is inherited by a class in the main application, say
> > "SonOfFred", then when some "local" call in Fred, for example
> > Fred.Describe, if this method is also provided in SonOfFred then the
> > actual method, SonOfFred.Describe is invoked.
> > 
> > But in this case, there is a trick needed in gambas 3.  You need to
> > provide a "stub" method in the base class, to stop the IDE/compiler
> > complaining. Let me expand.  If SonOfFred has a method "Decode" that you
> > wish to be able to be called (or in fact, invoked by the base class in
> > some way,) then you need to create a stub method in Fred.  I see this as
> > the base class defining a method that must be overridden, IOW a sort of
> > virtual method.  Mainly I implement the stub to raise an error if it is
> > invoked, i.e. in Fred we have:
> > 
> >   Public Sub Decode()
> >     Error.Raise("Decode not overridden correctly")
> >   End
> > 
> > In your case though (assuming that by "Form" you mean the native gambas
> > "Form" class), this will not work.  The only quick answer I can think of
> > is to use an event in the component that is going to (hopefully) be
> > handled adequately in the application.  Bit of a lottery though.
> > 
> > Or perhaps I haven't quite got your central issue here?
> > 
> > Bruce
> > 
> On rereading what I just said, I think I wrote a "when you have a
> hammer, everything looks like a nail" answer.
> 
> Send more details on what your problem/goal is.
> B

Salut Bruce,

what I have is an application which can run as is, 
but while compiled as component I can use it also in other projects.
This I do for not using SHELL etc.


And now I would like to have a feedback from what's done there. 

My first steps, passing the 'Me.Name & ".myCallBack"' => Form.Function
as string and ran that by eval, worked ok, but for that it was from a
form/Class inside the project, where  'Form.Function' is known.
-- 
Amicalement
Charlie





More information about the User mailing list