summary refs log tree commit diff stats
path: root/examples/tclex.nim
blob: 6d6d45b8febd8227c6803e53133fc440eb72acb3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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")