Autore Topic: Controllare Gambas con Gambas (eseguire istruzioni arbitrarie dinamicamente)  (Letto 519 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.722
  • Ne mors quidem nos iunget
    • Mostra profilo
Vorrei riportare - in lingua originale - qui nel forum una discussione apparsa ultimamente nella M.L.I.:

" Dear all,

is there a way to execute arbitrary statements dynamically in Gambas
(for example from a string)? If I understand correctly Eval only
evaluates expressions, but statements like print or function
definitions cannot be handled that way. What I would like to do is to
provide a scripting interface for my application, e.g. giving users
the opportunity to create a macro in gambas, providing it with
selected objects from the app (a context) and allow them to directly
execute them. Allowing other languages like Python, Ruby, Tcl would be
great as well, but I guess this could be done if I could do the first
part.

Can it be done? Or is there maybe some other way of implementing a
scripting interface?

Markus Schatten, PhD
Assistant professor
University of Zagreb
"


" There was a recent thread on the list about enabling a plugins
interface for the IDE (or any other Gambas app). With the current
tools made available to the developer, the DBus component is the
closest thing to what you are looking for. The "context" could be a
DBusObject, which any other application can call, either made in
gambas or not, you only need a DBus interface. See this link [1] for
an example. The full thread is available here [2].

Another way, but possibly really hard to code for it to be safe, would
be to use the Component.Load [3] function. This would give the said
component full access to your app, but maybe that's not what you are
looking for.

Hope this helps!

* [1] http://gambaswiki.org/wiki/comp/gb.dbus/dbusconnection/register

* [2] http://www.mail-archive.com/gambas-user@lists.sourceforge.net/msg20862.html

* [3] http://gambaswiki.org/wiki/comp/gb/component/load

Sebastian Kulesz
"
« Ultima modifica: 25 Agosto 2020, 11:50:23 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. »