[Gambas-user] Get the object of a component by name.

Matias De lellis mati86_dl at ...1877...
Wed Feb 24 00:42:39 CET 2016


Hi,

> I'm not sure if I understand you correctly. [ In case I don't, I would
> suggest that you maybe use pseudo code and simpler (Gambas-only) terms to
> state what you want to do. I mean: should I be required to look up the
> "Firmata protocol" and "Ctrlr" and "MIDI" to answer your question about a

> Gambas programming technique? --- Ideally, no. ]

Ok, bus as is the user list and not devel, introduced in case anyone was interested. ;)

> So, what I read out of your mail is that you have one object Firmata1 which
> has a certain configuration. You now want to add controls dynamically to the
> Form which should inherit Firmata1's configuration by obtaining a reference
> to the Firmata1 object.


Not completely dynamic.. After completing write the controls the idea is just change the list of properties of the controls placed on the form. (Not writing a single line of code more after design forms)
> If this understanding is correct, you have several possibilities, three of
> which are:
>
>  1. Why must Firmata be an instantiable class? Wouldn't a module suffice
>     here? (A module is a special kind of class which only has one instance.
>     If you only have one serial port to communicate with in your
>     application, a module should be fine.) Modules are like global
>     variables so it will be easy for your controls to obtain a reference
>     to this object.


I do not want to limit the ports, but to start i will take into account.

>  2. Can't you pass the Firmata1 object to the constructors of the controls?

Would be ideal, but I do not see how. Justly my idea was to add a property representing the instance name, and get the instance itself from that. http://gambaswiki.org/wiki/comp/gb/class/instance seems ideal but not work here..

>  3. (A refinement of 2.) Make the Firmata class a Container object and
>     create the controls inside the container Firmata1. This way, the
>     controls can access their parent Firmata1 and its configuration
>     directly. This is how the DataSource control from gb.db.form works,
>     if you are familiar with that.


I will investigate this option..

Thanks,




More information about the User mailing list