Modifying things with Automatic inheritance (Quick HowTo)
Posted
Regular

Perhaps I misunderstood something but in Gambas Documentation, I read:
3.2. Which class can be a parent class?
You can inherit any class, even a native one!
??????
I have a complete and stable app (Dio-Commander 2.0) which is a domotic app.
To add some stuff, i code some plugin's, my first plugin use an observer to catch a Button event and it work perfectly.
But my second plugin's must add some stuff to an existing sub in the master app.
Modifying code of master app is a nonsense for me, this must be plugin which intercept calls to this sub, add stuff and transfer the control to this sub. The only way, I think, is override the class, or perhaps, only the sub….But I don't know how I can make this.
For instance, I've tried inherit but without success !
Is my explanations are clear ?
regards
Olivier
Posted
Guru

Take a look at the gb.eval.highlight component classes. comp/src/gb.eval.highlight/.src · master · Gambas / gambas · GitLab you can see how Benoit does it.
There we have TextHighlighter.class
But also there is TextHighlighter_Sh.class and various others that all inherit TextHighlighter.class
Or if you want to make a small test project i can load and from there we can probably get it to do what you need
Posted
Regular

For example:
In my principal app i've:
Public sub mafonction()
end
In my plugin's (not present at principal ap development), I have:
Public sub mafonction()
end
I need that my plugin intercept the call of mafonction() of principal ap to redirect the call to mafonction() in plugin.
regards
Olivier
Posted
Guru

gambas does not expect your gambas code to be dynamic. it expects to compile it and pack it into an executable and is then done with compiling.
How it works…
The compiler first compiles the project dir with gbc3 (that compiles the binaries in .gambas/ dir)
The archiver then makes the executable with gba3 (makes Name.gambas)
then you run it
either run the .gambas executable (that uses gbr3)
or run the project itself (that uses gbx3)
So if you have run the program either by gbr3 or gbx3 any dynamically added gambas code has not been compiled yet and will need compiling with gbc,
So you cannot do it that way.
If you look at how Benoit is doing things like this see the new gb.highlight component or the new packaging suite that both have dynamically added configuration files that are converted by the program to it's requirement. gb.highlight uses lines of regex expressions.
From what I can tell dynamically adding gambas code to a ready compiled program cannot work.
Maybe if it is simple code you could use Eval() on the strings.
or maybe with gbs3 scripting to run gambas script code in your program. but only as a Shell/Exec process, it cannot fully integrate into your program.
Hope that makes sense.
Posted
Regular

You can download last version of my project (sources ares included) at this adress: DIO-Commander 2.0.95 - Gambas France
I think you understand what I need when you see the code
Please, be indulgent, my codes are always "bizarres"……. :roll: :roll:
Regards
Olivier
1 guest and 0 members have just viewed this.


