Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bug with embedded TCL in C using package require

Status
Not open for further replies.

dcelso

Programmer
Sep 29, 2005
11
ES
Hello to all,
I m trying to run serveral TCL commands inside C++ source code and when I show the information of the auto_path it is empty.
If I put the same command in the tclsh interpreter it runs well.

What Am I doing bad?
in tclsh I insert:
puts $auto_path
puts hola
package require Tk

and runs well.

my c souce code is the next:
#include <tcl.h>
#include <stdlib.h>
int main(int argc, char**argv) {
Tcl_Interp *interp;
int status;
char *comandos[] = { "puts $auto_path","set auto_path /usr/lib/","puts $auto_path","auto_load","puts hola",
"package require Tk", "package require clock",
, "", NULL };
interp = Tcl_CreateInterp();
if (interp == NULL) {
printf("can not create tcl interpreter\n");
exit(EXIT_FAILURE);
}
int i = 0;
Tcl_Obj *obj;
while (comandos != NULL) {
status = Tcl_Eval(interp, comandos);
if (interp->result[0] != 0) {
printf("%s\n", interp->result);
}
i++;
}
return EXIT_SUCCESS;
}

The result of the execution is:
can't read "auto_path": no such variable
/usr/lib/
/usr/lib/
invalid command name "auto_load"
hola
can't find package Tk
can't find package clock
can't find package AglClient
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top