Skip to content

Instantly share code, notes, and snippets.

Created Oct 26, 2020
What would you like to do?
TCL is easy to embed!
lib LibTcl
type Tcl_FreeProc = Void*
fun Tcl_SetVar(interp : Tcl_Interp*, varName : LibC::Char*, newValue : LibC::Char*, flags : Int32) : LibC::Char*
fun Tcl_Eval(interp : Tcl_Interp*, script : LibC::Char*) : Int32
fun Tcl_CreateInterp : Tcl_Interp*
struct Tcl_Interp
result : LibC::Char*
freeProc : Tcl_FreeProc
errorLine : Int32
my_string = "MagicWord"
puts("The secret is '#{my_string}'")
interp = LibTcl.Tcl_CreateInterp
variable_name = "my_string"
LibTcl.Tcl_SetVar(interp, variable_name, my_string, 0)
script = <<-END_SCRIPT
puts "Within this Tcl script, my_string has the value '$my_string'."
LibTcl.Tcl_Eval interp, script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment