When the interpreter invokes a C++ method, it expects the result back in the private member variable, tcl_-result. Two methods are available to set this variable.
Pass the result string s back to the interpreter.
varargs(3) variant of above to format the result using vsprintf(3), pass the result string back to the interpreter.
if (strcmp(argv[1], "now") == 0) { {\bfseries{}tcl.resultf}("%.17g", clock()); return TCL_OK; } {\bfseries{}tcl.result}("Invalid operation specified"); return TCL_ERROR;
Likewise, when a C++ method invokes an OTcl command, the interpreter returns the result in tcl_-result.
tcl.evalc("Simulator set NumberInterfaces_"); char* ni = {\bfseries{}tcl.result}(); if (atoi(ni) != 1) tcl.evalc("Simulator set NumberInterfaces_ 1");