Next: CONFIGURING THE IMAKEFILE Up: PROPAGATION PATTERNS Previous: A Longer Example

Calling Tcl from Propagation Patterns

There are currently two differentways to call TclTk functionality from C++ code. The first is to use the Tcl functions Tcl_GlobalEval, Tcl_Eval, &Tcl_Interp. And an example:


char cmd [300]

	extern Tcl_Interp *interp;
	sprintf(cmd, "dialog_label NAME {%s} ...", name, ...);
	Tcl_GlobalEval(interp, cmd);

And the other way is to use isthmus-cd, which contains the object tclexec, and isthmus-pp. The Tcl interpreter executes all strings which are sent to this new object. So it is no longer necessary to use Tcl_Eval, &Tcl_Interp.

An brief example of using the new object follows.

The cd.cd:


X = <y> Y.
Y = <n> DemNumber.

With a propagation pattern:


(@ #include "tclexec.h" @)
*operation* void t()
*traverse*
*from* X 
*to* Y

*wrapper* Y
(@
  cout << "I'm @ Y"<< endl;
  tclexec << "puts \"Me too\"" ;
  // executes the tcl command `puts "Me too"'
@)

This only works when the line include tclexec.h is in the propagation pattern or when the line

 #include ``tclexec.h''
is manually added to the file global.h. An important restriction to the use of this method is that it only works when Isthmus is run with the wish option .


gollum@ccs.neu.edu
Fri Mar 17 08:23:12 EST 1995