summary refs log tree commit diff stats
path: root/examples/tclex.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2009-06-08 08:13:09 +0200
committerAndreas Rumpf <rumpf_a@web.de>2009-06-08 08:13:09 +0200
commit36818817bd61594ea6d106328bb8df0f5a25cfc4 (patch)
tree58180069c9a32400e7e11ba5bc5c85be2f11f0cc /examples/tclex.nim
parent4d4b3b1c04d41868ebb58bd9ccba7b303007e900 (diff)
downloadNim-36818817bd61594ea6d106328bb8df0f5a25cfc4.tar.gz
version0.7.10
Diffstat (limited to 'examples/tclex.nim')
-rw-r--r--examples/tclex.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/tclex.nim b/examples/tclex.nim
new file mode 100644
index 000000000..6d6d45b8f
--- /dev/null
+++ b/examples/tclex.nim
@@ -0,0 +1,25 @@
+# Example to embed TCL in Nimrod
+
+import tcl, os
+
+const
+  myScript = """puts "Hello, World - In quotes" """
+  myScript2 = """
+package require Tk
+pack [entry .e -textvar e -width 50]
+bind .e <Return> {
+  set e  [regsub { *=.*} $e ""] ;# remove evaluation (Chris)
+  catch {expr [string map {/ *1./} $e]} res
+  append e " = $res"
+}  
+"""
+
+Tcl_FindExecutable(getApplicationFilename())
+var interp = Tcl_CreateInterp()
+if interp == nil: quit("cannot create TCL interpreter")
+if Tcl_Init(interp) != TCL_OK: 
+  quit("cannot init interpreter")
+if Tcl_Eval(interp, myScript) != TCL_OK: 
+  quit("cannot execute script.tcl")
+
+