Autore Topic: Invocare l'interprete da un programma compilato  (Letto 203 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.683
  • Ne mors quidem nos iunget
    • Mostra profilo
Invocare l'interprete da un programma compilato
« il: 10 Febbraio 2015, 09:35:02 »
Vi riporto questa discussione:

" 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.

VonZorch
"


" 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
"


" I don't think so. In old Clipper 5 I had a database with "codeblocks" that
you can load in execution time... but this is a big hole in security, I
guess...

Regards
Jorge
"
« Ultima modifica: 10 Febbraio 2015, 11:50:00 da vuott »
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »