Skip to content

Instantly share code, notes, and snippets.

@wmoxam
Created Oct 26, 2020
Embed
What would you like to do?
TCL is easy to embed!
@[Link("tcl")]
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
end
end
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'."
END_SCRIPT
LibTcl.Tcl_Eval interp, script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment