Skip to content

Instantly share code, notes, and snippets.

@bdrewery
Created August 23, 2010 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdrewery/544660 to your computer and use it in GitHub Desktop.
Save bdrewery/544660 to your computer and use it in GitHub Desktop.
C++ Scripting API example
ScriptInterpTCL tcl_script;
tcl_script.init();
String x("54321");
tcl_script.linkVar("x", x);
// Test Getting var from C++
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x"));
x = "test 1 2 3 4 5 ";
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x"));
// Test Setting var from TCL
String newval("5 4 2 3 1 test");
tcl_script.eval(String("set x \"") + newval + "\"");
CPPUNIT_ASSERT_STRING_EQUAL(newval, tcl_script.eval("set x"));
// Test getting a substring
x = newval(0, 5);
CPPUNIT_ASSERT_STRING_EQUAL(x, tcl_script.eval("set x"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment