[vtkusers] How to run vtk tcl script in c/c++

Chen Fu novalet at yahoo.com.cn
Tue Apr 8 04:12:32 EDT 2003


Hi!
I recently working on an application which is written
in c++ and it will generate vtk tcl script. 
I formerly run these script in windows explorer. They
work nice. But to make the work more fluently, i try
to run it in application itself when the user press
some button.
But i didn't work it out.

Look, there is some simple sample i borrowed from web.

======================================================================================
#include <stdio.h>
#include <stdlib.h>
#include <tcl.h>			/* defines TCL structures/procs
etc... */
main(int argc, char *argv[]) 
{
	Tcl_Interp *interpreter;
	int status;
	char cmd[]="proc incr {n} {return [expr $n+1]};set n
5;puts \"incr $n=[incr $n]\";return Tcl_Eval";

	/* get filename from command line */
	if (argc != 2) {
		fprintf (stderr,"expected a TCL script file:e.g.
\"%s fileName\"\n", argv[0]);
		exit(1);
	}

	/* create a new TCL interpreter, which contains all
the TCL commands
	but no TCL variables, procedures and has an empty
executuion stack */
	interpreter = Tcl_CreateInterp();

	/* Tcl_EvalFile passes the TCL script as a file */
	status = Tcl_EvalFile(interpreter, argv[1]);
	if (*interpreter->result != 0) printf("computed by
%s\n", interpreter->result); 
======================================================================================

If i try to run a simple tcl scripts, for example
============================
puts "Hello world"
============================
it works. the console will receive "Hello world"

but when i try to use a vtk script in various testing
scripts in vtk4.2.1,  the status returned is TCL_OK,
but nothing happen in screen.

If i try wish83 with this script, it works. So i think
it is not a problem of TCLLIBPATH.

any guru can give me some suggestion?

PS. my OS is win2k, and vtk4.2.1, tcl/tk 8.3

=====
Remote Scensing Satellite Ground Station
Chinese Academy of Science

_________________________________________________________
Do You Yahoo!? 
雅虎通网络KTV, 随时随地免费卡拉OK~~
http://rd.yahoo.com/mail_cn/tag/?http://cn.messenger.yahoo.com//chat/index.html



More information about the vtkusers mailing list