[Gambas-user] Invoking interpreter from complied program

Tobias Boege taboege at ...626...
Tue Feb 10 02:21:33 CET 2015


On Mon, 09 Feb 2015, VonZorch wrote:
> Is it possible for a compiled program to read instructions from a text file?
> I'm trying to write a program that can have functions added without needing
> to recompile the base program.
> 

Of course you can *read* them (File.Load()). You can also execute certain
types of Gambas source code (a subset of Gambas one-liners) from a string
variable at runtime (Eval()) and you can write, rewrite and execute whole
projects and scripts (Shell "gbx3 ...", Shell "gbs3 ...").

The only difficult thing is if you want to make plugins with this, where by
"plugin" I mean external Gambas classes which interact with your classes in
a single Gambas process. You can achieve a limited form of this without own
effort using Eval() and a Collection where you store the plugin environment.
But as briefly mentioned above, you can only have certain types of one-line
code with Eval(). Suitable if you want to be able to add very simple math
functions, macro abilities or the like to your program (but beware of giving
random text files access to Eval() as it is a gate to each and every public
symbol in your process).

The definitive answer to your question depends on what you didn't tell us
about your goal.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list