On Thu, 9 Mar 2000, Chen Shapira wrote:

> > 2. Support the use of a scripting language (such as Tcl, Perl 
> > or Python)
> >    interpreted by an embedded interpreter.
> >    This will allow other people to turn your word processor into a
> >    sophisticated and complicated and feature-rich one by 
> > adding their own
> >    commands (implemented as scripts).
> > 
> 
> I was always wondering how does one go about adding scripting capabilites to
> a program.
> Does anyone know of any resources about the subject?

Any serious book about Tcl has some stuff about embedding Tcl interpreter
in C programs.  The bulk of the stuff is about accessing Tcl variables
from C/C++ code and about accessing C/C++ variables from Tcl code.

Basically, you structure your application so it has clean separation
between the GUI and the "engine" (the part which actually erases your
M.Sc. thesis if you select the entire file and hit CTRL-X).

Anything which you can activate from your application's menu - should be
implemented as a distinct procedure (with or without parameters).
Then you define a keyword (to serve as Tcl command) for each procedure.
When your Tcl script mentions that keyword, the corresponding procedure is
invoked by the code which you wrote to embed the Tcl interpreter.

It is not that complicated.  I have done so in several projects.

O'Reilly's book "Advanced Perl Programming" by Sriram Srinivasan has
information about embedding Perl interpreters in your own application and
vice versa (adding your own application as an extension to Perl).

About Python - I defer to the Pythonophiles in the Linux-IL mailing
list.
                                         --- Omer


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to