Reputation: 10959
I need simple C/C++ program which creates a Tcl_Obj
, set some value to it and prints that value. I need to see how it can be done using C API. Here is what I have done so far.
#include <tcl.h>
int main() {
Tcl_Interp *interp = Tcl_CreateInterp();
Tcl_Obj* tclObj = new Tcl_NewObj();
// setting tclObj some value
// printing it using something like this Tcl_PrintVariable(tclObj);
return 0;
}
Upvotes: 1
Views: 312
Reputation: 499
/*set value */
Tcl_SetIntObj(tclObj, 3);
/*print value*/
int i;
Tcl_GetIntFromObj(interp, tclObj, &i);
printf("Value: %d\r\n", i);
Also better to check return value of Tcl_GetIntFromObj(). Refer to this page - Tcl reference manual
Upvotes: 2