Created
October 26, 2020 23:50
-
-
Save wmoxam/07500dbdbc4be422f2eaed1d38c00726 to your computer and use it in GitHub Desktop.
TCL is easy to embed!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[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